This is an automated email from the ASF dual-hosted git repository.

markap14 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git


The following commit(s) were added to refs/heads/main by this push:
     new dc6ba25  NIFI-8024 Added null claim check to 
EncryptedFileSystemRepository.read() to avoid EOFException
dc6ba25 is described below

commit dc6ba2541f13db9666a491fd3b0ce701f318f900
Author: exceptionfactory <[email protected]>
AuthorDate: Wed Nov 18 15:38:04 2020 -0500

    NIFI-8024 Added null claim check to EncryptedFileSystemRepository.read() to 
avoid EOFException
---
 .../repository/crypto/EncryptedFileSystemRepository.java           | 4 ++++
 .../repository/crypto/EncryptedFileSystemRepositoryTest.groovy     | 7 +++++++
 2 files changed, 11 insertions(+)

diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/repository/crypto/EncryptedFileSystemRepository.java
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/repository/crypto/EncryptedFileSystemRepository.java
index 4b8adc4..676639c 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/repository/crypto/EncryptedFileSystemRepository.java
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/repository/crypto/EncryptedFileSystemRepository.java
@@ -168,6 +168,10 @@ public class EncryptedFileSystemRepository extends 
FileSystemRepository {
     public InputStream read(final ContentClaim claim) throws IOException {
         InputStream inputStream = super.read(claim);
 
+        if (claim == null) {
+            return inputStream;
+        }
+
         try {
             String recordId = getRecordId(claim);
             logger.debug("Creating decrypted input stream to read flowfile 
content with record ID: " + recordId);
diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/groovy/org/apache/nifi/controller/repository/crypto/EncryptedFileSystemRepositoryTest.groovy
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/groovy/org/apache/nifi/controller/repository/crypto/EncryptedFileSystemRepositoryTest.groovy
index 0b5ce89..5c03690 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/groovy/org/apache/nifi/controller/repository/crypto/EncryptedFileSystemRepositoryTest.groovy
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/groovy/org/apache/nifi/controller/repository/crypto/EncryptedFileSystemRepositoryTest.groovy
@@ -159,6 +159,13 @@ class EncryptedFileSystemRepositoryTest {
         Cipher.getMaxAllowedKeyLength("AES") > 128
     }
 
+    @Test
+    void testReadNullContentClaimShouldReturnEmptyInputStream() {
+        final InputStream inputStream = repository.read(null)
+        final int read = inputStream.read()
+        assert read == -1
+    }
+
     /**
      * Simple test to write encrypted content to the repository, independently 
read the persisted file to ensure the content is encrypted, and then retrieve & 
decrypt via the repository.
      */

Reply via email to