markap14 commented on a change in pull request #4736:
URL: https://github.com/apache/nifi/pull/4736#discussion_r545996775



##########
File path: 
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/TailFile.java
##########
@@ -799,7 +799,8 @@ public void process(final OutputStream rawOut) throws 
IOException {
 
         if (abort.get() != null) {
             session.remove(flowFile);
-            tfo.setState(new TailFileState(tailFile, file, reader, position, 
timestamp, length, checksum, state.getBuffer()));
+            // store the new position and set the reader to null to 
reinitialize and reposition it
+            tfo.setState(new TailFileState(tailFile, file, null, 
positionHolder.get(), timestamp, length, checksum, state.getBuffer()));

Review comment:
       We can't just abandon the existing `reader` here, as we need to make 
sure that it gets closed. Otherwise we'd be leaking a file handle. But I don't 
think we really want to close and abandon the reader we already have anyway. 
Since we know where we want the reader to be positioned, we should be able to 
just use `reader.position(positionHolder.get());` no?




----------------------------------------------------------------
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


Reply via email to