Fixed few coverity issues for resource synchronization

This commit is contained in:
Santhosh Edukulla 2014-08-04 16:00:36 +05:30
parent 73ac5dd9d0
commit b7d3f1bd30
2 changed files with 4 additions and 7 deletions

View File

@ -272,16 +272,14 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl
public int registerForInitialConnects(final StartupCommandProcessor creator, boolean priority) {
synchronized (_hostMonitors) {
_monitorId++;
if (priority) {
_creationMonitors.add(0, new Pair<Integer, StartupCommandProcessor>(_monitorId, creator));
} else {
_creationMonitors.add(new Pair<Integer, StartupCommandProcessor>(_monitorId, creator));
}
}
return _monitorId;
}
}
@Override
public void unregisterForHostEvents(final int id) {

View File

@ -1438,11 +1438,10 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
@Override
public void registerResourceStateAdapter(String name, ResourceStateAdapter adapter) {
synchronized (_resourceStateAdapters) {
if (_resourceStateAdapters.get(name) != null) {
throw new CloudRuntimeException(name + " has registered");
}
synchronized (_resourceStateAdapters) {
_resourceStateAdapters.put(name, adapter);
}
}