Ejemplo n.º 1
0
    /**
     * Removes all ConnectionInfos from tracking where for the key & passed in Connection
     *
     * @param key the connection key
     * @param con the connection to remove
     */
    private static synchronized void remove(String key, Connection con) {
      final Collection<ConnectionInfo> conInfos = getConnectionInfos(key);
      for (Iterator<ConnectionInfo> i = conInfos.iterator(); i.hasNext(); ) {
        final ConnectionInfo conInfo = i.next();
        if (conInfo.getConnection() == con) {
          i.remove();
        }
      }

      OPEN_CONNECTIONS.get().put(key, conInfos);
    }
Ejemplo n.º 2
0
    /**
     * logs a message related to multiple connections being open.
     *
     * @param key the connection key
     */
    private static synchronized void logMultipleConnections(String key) {
      final Collection<ConnectionInfo> conInfos = OPEN_CONNECTIONS.get().get(key);
      if (conInfos != null && !conInfos.isEmpty()) {
        final StringBuilder stacks = new StringBuilder();

        for (ConnectionInfo conInfo : conInfos) {
          stacks.append(conInfo.getEstablishedStack());
          stacks.append("\n\n");
        }

        final StringBuilder msg = new StringBuilder();
        msg.append("There are ");
        msg.append(conInfos.size());
        msg.append(" connection(s) on this thread ");
        msg.append(Thread.currentThread().getName());
        msg.append(" to ");
        msg.append(key);
        msg.append(" that have not been closed.");
        msg.append(" The following stacktraces show where these connections were established: \n");
        msg.append(stacks);

        LOG.debug(msg);
      }
    }