Github user olegz commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/584#discussion_r101118510
  
    --- Diff: 
nifi-external/nifi-spark-receiver/src/main/java/org/apache/nifi/spark/NiFiReceiver.java
 ---
    @@ -162,17 +162,19 @@ public void run() {
                             }
     
                             final List<NiFiDataPacket> dataPackets = new 
ArrayList<>();
    +                        InputStream inStream =null;
                             do {
                                 // Read the data into a byte array and wrap it 
along with the attributes
                                 // into a NiFiDataPacket.
    -                            final InputStream inStream = 
dataPacket.getData();
    +                            inStream = dataPacket.getData();
                                 final byte[] data = new byte[(int) 
dataPacket.getSize()];
                                 StreamUtils.fillBuffer(inStream, data);
     
                                 final Map<String, String> attributes = 
dataPacket.getAttributes();
                                 final NiFiDataPacket NiFiDataPacket = new 
StandardNiFiDataPacket(data, attributes);
                                 dataPackets.add(NiFiDataPacket);
                                 dataPacket = transaction.receive();
    +                            inStream.close();
    --- End diff --
    
    While generally it is indeed necessary to close the resources to avoid 
unnecessary memory leaks, this is not the right place to do that since 
NiFiReceiver is not the creator/owner of the stream and if another handle exist 
for such stream it could lead to unexpected results. We should probably 
investigate where this stream is created and ensure that it is closed there.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to