You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2022/11/08 18:17:35 UTC

[GitHub] [nifi] tpalfy commented on a diff in pull request #6620: NIFI-10702 Clear server list on connection error in SMB processors

tpalfy commented on code in PR #6620:
URL: https://github.com/apache/nifi/pull/6620#discussion_r1016972231


##########
nifi-nar-bundles/nifi-smb-bundle/nifi-smb-smbj-client/src/main/java/org/apache/nifi/services/smb/SmbjClientProviderService.java:
##########
@@ -129,6 +129,7 @@ public SmbClientService getClient() throws IOException {
             getLogger().debug("Closing stale connection and trying to create a new one for share " + getServiceLocation());
 
             closeConnection(connection);
+            unregisterHost();

Review Comment:
   Unfortunately
   ```java
   Connection connection = smbClient.connect(hostname, port);
   ```
   can also fail for the same reason this change is trying to fix.
   
   To my understanding this is because how the connection is cached by the SMBClient.
   Our current approach increases the number of leases on the cached connection every time we ask for one. And those leases are never "returned" by us. So the number of leases increases indefinitely and can almost never reach zero. Except when we have asked for a connection _only once_. If the connection is closed after this first occurrence the number of leases reaches zero and it is discarded.
   
   However the server hostname is already stored so if that changes an exception comes when we ask the client to create a new connection.
   
   Long story short, the
   ```java
   smbClient.connect(hostname, port);
   ```
   call should be in a try-catch block as well.



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

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org