void (@NotNull String text, @NotNull Key outputType) { if (text.isEmpty()) { return; } if (ProcessOutputType.isStdout(outputType)) { processStdOutConsistently(text, outputType); } else { List<OutputChunk> chunksToFlush = null; List<OutputChunk> chunks = outputType == ProcessOutputTypes.SYSTEM ? mySystemChunks : myStdErrChunks; //noinspection SynchronizationOnLocalVariableOrMethodParameter synchronized (chunks) { OutputChunk lastChunk = ContainerUtil.getLastItem(chunks); if (lastChunk != null && outputType.equals(lastChunk.getKey())) { lastChunk.append(text); } else { chunks.add(new OutputChunk(outputType, text)); } if (StringUtil.endsWithChar(text, NEW_LINE)) { chunksToFlush = new ArrayList<>(chunks); chunks.clear(); } } if (chunksToFlush != null) { onChunksAvailable(chunksToFlush, false); } } }