SPV is failing if Admin state
[oam/tr069-adapter.git] / netconf-server / src / main / java / org / commscope / tr069adapter / netconf / server / helper / ServerPortAllocationHelper.java
index f5ff597..9e5479d 100644 (file)
@@ -75,8 +75,8 @@ public class ServerPortAllocationHelper {
     }\r
     LOG.debug("Successfully populated available ports list.");\r
   }\r
-\r
-  public String reserveServerPort() throws ServerPortAllocationException {\r
+  \r
+  public synchronized String reserveServerPort() throws ServerPortAllocationException {\r
 \r
     if (availablePorts.isEmpty()) {\r
       LOG.debug(\r
@@ -89,6 +89,7 @@ public class ServerPortAllocationHelper {
     LOG.debug("Trying to reserve port : {}", port);\r
     if (isServerPortInUse(port)) {\r
       LOG.debug("Port {} is already in use.", port);\r
+      availablePorts.poll();\r
       return reserveServerPort(); // retry if current port is not available\r
     }\r
 \r