Fix unsafe global config access
[netconf.git] / netconf / callhome-provider / src / main / java / org / opendaylight / netconf / callhome / mount / CallHomeAuthProviderImpl.java
index ed7f2ac4d7beeeb73a2706253aa1938a3e309a1e..d0c6905291f42368faa21499db8837cf8fbb2699 100644 (file)
@@ -236,7 +236,6 @@ public class CallHomeAuthProviderImpl implements CallHomeAuthorizationProvider,
     }
 
     private static class GlobalConfig implements DataTreeChangeListener<Global> {
-
         private volatile Global current = null;
 
         @Override
@@ -247,15 +246,14 @@ public class CallHomeAuthProviderImpl implements CallHomeAuthorizationProvider,
         }
 
         boolean allowedUnknownKeys() {
-            if (current == null) {
-                return false;
-            }
+            final Global local = current;
             // Deal with null values.
-            return Boolean.TRUE.equals(current.isAcceptAllSshKeys());
+            return local != null && Boolean.TRUE.equals(local.isAcceptAllSshKeys());
         }
 
         Credentials getCredentials() {
-            return current != null ? current.getCredentials() : null;
+            final Global local = current;
+            return local != null ? local.getCredentials() : null;
         }
     }
 }