Pingping Lin
Committed by Gerrit Code Review

thread safe improvment

Change-Id: I09b6dc7a3003792ec975b5b8c8c423d38d65767b
......@@ -112,7 +112,8 @@ public class VbngConfigurationManager implements VbngConfigurationService {
// TODO handle the case: the number of public IP addresses is not enough
// for 1:1 mapping from public IP to private IP.
@Override
public IpAddress getAvailablePublicIpAddress(IpAddress privateIpAddress) {
public synchronized IpAddress getAvailablePublicIpAddress(IpAddress
privateIpAddress) {
// If there is already a mapping entry for the private IP address,
// then fetch the public IP address in the mapping entry and return it.
IpAddress publicIpAddress = ipAddressMap.get(privateIpAddress);
......
......@@ -47,10 +47,8 @@ public class VbngResource extends BaseResource {
VbngService vbngService = get(VbngService.class);
IpAddress publicIpAddress = null;
synchronized (this) {
// Create a virtual BNG
publicIpAddress = vbngService.createVbng(privateIpAddress);
}
// Create a virtual BNG
publicIpAddress = vbngService.createVbng(privateIpAddress);
if (publicIpAddress != null) {
return publicIpAddress.toString();
......