void (Map<String, Integer> traces) { String mostFrequentTraces = EntryStream .of(traces) .sortedByInt(e -> -e.getValue()) .map(e -> e.getValue() + " occurrences of " + e.getKey()) .limit(10) .joining("\n\n"); if (LOG.isDebugEnabled()) { LOG.debug(mostFrequentTraces); } Attachment attachment = new Attachment("diagnostic.txt", mostFrequentTraces); attachment.setIncluded(true); LOG.error(TOO_MANY_NON_BLOCKING_READ_ACTIONS_SUBMITTED_AT_ONCE + ". " + SUGGESTIONS, attachment); }