Beispiel #1
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);
      }
    }