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

tpalfy 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 15a46ce589 NIFI-14553 Workaround for NPE in ListSmb due to DFS folders 
having no target mapping
15a46ce589 is described below

commit 15a46ce589f2aff119bcc4b2be6ab3160b01469d
Author: Peter Turcsanyi <[email protected]>
AuthorDate: Thu May 8 22:30:45 2025 +0200

    NIFI-14553 Workaround for NPE in ListSmb due to DFS folders having no 
target mapping
    
    This closes #9925.
    
    Signed-off-by: Tamas Palfy <[email protected]>
---
 .../org/apache/nifi/services/smb/SmbjClientService.java    | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git 
a/nifi-extension-bundles/nifi-smb-bundle/nifi-smb-smbj-client/src/main/java/org/apache/nifi/services/smb/SmbjClientService.java
 
b/nifi-extension-bundles/nifi-smb-bundle/nifi-smb-smbj-client/src/main/java/org/apache/nifi/services/smb/SmbjClientService.java
index 6e0ab503b6..71ec38ee27 100644
--- 
a/nifi-extension-bundles/nifi-smb-bundle/nifi-smb-smbj-client/src/main/java/org/apache/nifi/services/smb/SmbjClientService.java
+++ 
b/nifi-extension-bundles/nifi-smb-bundle/nifi-smb-smbj-client/src/main/java/org/apache/nifi/services/smb/SmbjClientService.java
@@ -40,6 +40,7 @@ import java.io.OutputStream;
 import java.net.URI;
 import java.util.EnumSet;
 import java.util.List;
+import java.util.Optional;
 import java.util.stream.Stream;
 
 class SmbjClientService implements SmbClientService {
@@ -89,6 +90,19 @@ class SmbjClientService implements SmbClientService {
                 } else {
                     throw e;
                 }
+            } catch (NullPointerException e) {
+                // workaround for https://github.com/hierynomus/smbj/issues/869
+                final boolean isNpeFromGetDiskEntry = 
Optional.ofNullable(e.getStackTrace())
+                        .filter(st -> st.length > 0)
+                        .map(st -> st[0])
+                        .map(ste -> 
ste.getClassName().equals(DiskShare.class.getName()) && 
ste.getMethodName().equals("getDiskEntry"))
+                        .orElse(false);
+                if (isNpeFromGetDiskEntry) {
+                    logger.warn("Could not list directory [{}/{}] because 
possibly no target is mapped to the directory in the DFS namespace", 
serviceLocation, directoryPath, e);
+                    return Stream.empty();
+                } else {
+                    throw e;
+                }
             }
 
             return stream(directory::spliterator, 0, false)

Reply via email to