ijokarumawak commented on a change in pull request #3578: NIFI-5952 [WIP] Fixing RAW S2S illegal blocking mode on Java 11 URL: https://github.com/apache/nifi/pull/3578#discussion_r301908370
########## File path: nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/codec/StandardFlowFileCodec.java ########## @@ -56,13 +62,32 @@ public void encode(final DataPacket dataPacket, final OutputStream encodedOut) t writeString(entry.getValue(), out); } - out.writeLong(dataPacket.getSize()); + final long dataSize = dataPacket.getSize(); + out.writeLong(dataSize); final InputStream in = dataPacket.getData(); - StreamUtils.copy(in, encodedOut); + copy(dataSize, in, encodedOut); encodedOut.flush(); } + private long copy(long length, final InputStream source, final OutputStream destination) throws IOException { + + final StopWatch stopWatch = new StopWatch(false); + final byte[] buffer = new byte[8192]; + long totalRead = 0; + // Use 'available' so that it doesn't block + for (int available; totalRead < length && (available = source.available()) > 0;) { Review comment: Thank you for catching this. I think this is a leftover while I was trying different things. Reverted changes to StandardFlowFileCodec. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services