Fixed few coverity reported issues around concurrency, null checks

This commit is contained in:
Santhosh Edukulla 2014-08-11 16:55:23 +05:30
parent f9e11540c7
commit fd96ad02d7
4 changed files with 35 additions and 23 deletions

View File

@ -60,7 +60,7 @@ public class RabbitMQEventBus extends ManagerBase implements EventBus {
private static String username;
private static String password;
public static void setVirtualHost(String virtualHost) {
public synchronized static void setVirtualHost(String virtualHost) {
RabbitMQEventBus.virtualHost = virtualHost;
}
@ -481,8 +481,7 @@ public class RabbitMQEventBus extends ManagerBase implements EventBus {
}
@Override
public boolean stop() {
public synchronized boolean stop() {
if (s_connection.isOpen()) {
for (String subscriberId : s_subscribers.keySet()) {
Ternary<String, Channel, EventSubscriber> subscriberDetails = s_subscribers.get(subscriberId);

View File

@ -359,20 +359,21 @@ public class HypervManagerImpl implements HypervManager {
private void shutdownCleanup() {
s_logger.info("Cleanup mounted mount points used in current session");
synchronized (_storageMounts) {
for (String mountPoint : _storageMounts.values()) {
s_logger.info("umount NFS mount: " + mountPoint);
for (String mountPoint : _storageMounts.values()) {
s_logger.info("umount NFS mount: " + mountPoint);
String result = null;
Script command = new Script(true, "umount", _timeout, s_logger);
command.add(mountPoint);
result = command.execute();
if (result != null) {
s_logger.warn("Unable to umount " + mountPoint + " due to " + result);
}
File file = new File(mountPoint);
if (file.exists()) {
file.delete();
String result = null;
Script command = new Script(true, "umount", _timeout, s_logger);
command.add(mountPoint);
result = command.execute();
if (result != null) {
s_logger.warn("Unable to umount " + mountPoint + " due to " + result);
}
File file = new File(mountPoint);
if (file.exists()) {
file.delete();
}
}
}
}

View File

@ -107,7 +107,7 @@ public class DummyHostServerResource extends ServerResourceBase {
return true;
}
public static int getNextSequenceId() {
public synchronized static int getNextSequenceId() {
return s_nextSequence++;
}

View File

@ -61,27 +61,39 @@ public class TestClock extends TimerTask {
}
public int getMinute() {
return _minute;
synchronized (this) {
return _minute;
}
}
public int getHour() {
return _hour;
synchronized (this) {
return _hour;
}
}
public int getDay() {
return _day;
synchronized (this) {
return _day;
}
}
public int getWeek() {
return _week;
synchronized (this) {
return _week;
}
}
public int getMonth() {
return _month;
synchronized (this) {
return _month;
}
}
public int getYear() {
return _year;
synchronized (this) {
return _year;
}
}
public int getMinutesPerHour() {