Skip to content

Commit

Permalink
findbugs: write to static from instance
Browse files Browse the repository at this point in the history
 these are the trivial cases of ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD
 as reported by findbugs
  • Loading branch information
DaanHoogland committed Jul 6, 2015
1 parent f1a6490 commit 764950d
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ public class ImageFormatHelper {

@Inject
public void setFormats(List<ImageFormat> formats) {
ImageFormatHelper.formats = formats;
ImageFormatHelper.initFormats(formats);
}

private static synchronized void initFormats(List<ImageFormat> newFormats) {
formats = newFormats;
}

public static ImageFormat getFormat(String format) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,8 @@
import javax.ejb.Local;
import javax.naming.ConfigurationException;

import org.apache.cloudstack.framework.events.Event;
import org.apache.cloudstack.framework.events.EventBus;
import org.apache.cloudstack.framework.events.EventBusException;
import org.apache.cloudstack.framework.events.EventSubscriber;
import org.apache.cloudstack.framework.events.EventTopic;
import org.apache.cloudstack.managed.context.ManagedContextRunnable;
import org.apache.log4j.Logger;

import com.cloud.utils.Ternary;
import com.cloud.utils.component.ManagerBase;
import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.AlreadyClosedException;
import com.rabbitmq.client.Channel;
Expand All @@ -51,6 +43,16 @@
import com.rabbitmq.client.ShutdownListener;
import com.rabbitmq.client.ShutdownSignalException;

import org.apache.cloudstack.framework.events.Event;
import org.apache.cloudstack.framework.events.EventBus;
import org.apache.cloudstack.framework.events.EventBusException;
import org.apache.cloudstack.framework.events.EventSubscriber;
import org.apache.cloudstack.framework.events.EventTopic;
import org.apache.cloudstack.managed.context.ManagedContextRunnable;

import com.cloud.utils.Ternary;
import com.cloud.utils.component.ManagerBase;

@Local(value = EventBus.class)
public class RabbitMQEventBus extends ManagerBase implements EventBus {

Expand Down Expand Up @@ -138,23 +140,23 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
return true;
}

public void setServer(String amqpHost) {
public static void setServer(String amqpHost) {
RabbitMQEventBus.amqpHost = amqpHost;
}

public void setUsername(String username) {
public static void setUsername(String username) {
RabbitMQEventBus.username = username;
}

public void setPassword(String password) {
public static void setPassword(String password) {
RabbitMQEventBus.password = password;
}

public void setPort(Integer port) {
public static void setPort(Integer port) {
RabbitMQEventBus.port = port;
}

public void setSecureProtocol(String protocol) {
public static void setSecureProtocol(String protocol) {
RabbitMQEventBus.secureProtocol = protocol;
}

Expand All @@ -163,11 +165,11 @@ public void setName(String name) {
this.name = name;
}

public void setExchange(String exchange) {
public static void setExchange(String exchange) {
RabbitMQEventBus.amqpExchangeName = exchange;
}

public void setRetryInterval(Integer retryInterval) {
public static void setRetryInterval(Integer retryInterval) {
RabbitMQEventBus.retryInterval = retryInterval;
}

Expand Down Expand Up @@ -378,7 +380,7 @@ private synchronized Connection createConnection() throws Exception {
}

if (useSsl != null && !useSsl.isEmpty() && useSsl.equalsIgnoreCase("true")) {
factory.useSslProtocol(this.secureProtocol);
factory.useSslProtocol(secureProtocol);
}
Connection connection = factory.newConnection();
connection.addShutdownListener(disconnectHandler);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,19 @@

public class KVMHAMonitor extends KVMHABase implements Runnable {
private static final Logger s_logger = Logger.getLogger(KVMHAMonitor.class);
private Map<String, NfsStoragePool> _storagePool = new ConcurrentHashMap<String, NfsStoragePool>();
private final Map<String, NfsStoragePool> _storagePool = new ConcurrentHashMap<String, NfsStoragePool>();

private String _hostIP; /* private ip address */
private final String _hostIP; /* private ip address */

public KVMHAMonitor(NfsStoragePool pool, String host, String scriptPath) {
if (pool != null) {
_storagePool.put(pool._poolUUID, pool);
}
_hostIP = host;
configureHeartBeatPath(scriptPath);
}

private static synchronized void configureHeartBeatPath(String scriptPath) {
KVMHABase.s_heartBeatPath = scriptPath;
}

Expand Down
31 changes: 21 additions & 10 deletions server/src/com/cloud/api/auth/APIAuthenticationManagerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,22 @@
// under the License.
package com.cloud.api.auth;

import com.cloud.utils.component.ComponentContext;
import com.cloud.utils.component.ManagerBase;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import javax.ejb.Local;

import org.apache.log4j.Logger;

import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.auth.APIAuthenticationManager;
import org.apache.cloudstack.api.auth.APIAuthenticator;
import org.apache.cloudstack.api.auth.PluggableAPIAuthenticator;
import org.apache.log4j.Logger;

import javax.ejb.Local;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.cloud.utils.component.ComponentContext;
import com.cloud.utils.component.ManagerBase;

@Local(value = APIAuthenticationManager.class)
@SuppressWarnings("unchecked")
Expand All @@ -52,17 +55,25 @@ public void setApiAuthenticators(List<PluggableAPIAuthenticator> authenticators)

@Override
public boolean start() {
s_authenticators = new HashMap<String, Class<?>>();
initAuthenticator();
for (Class<?> authenticator: getCommands()) {
APICommand command = authenticator.getAnnotation(APICommand.class);
if (command != null && !command.name().isEmpty()
&& APIAuthenticator.class.isAssignableFrom(authenticator)) {
s_authenticators.put(command.name().toLowerCase(), authenticator);
addAuthenticator(authenticator, command);
}
}
return true;
}

private static synchronized void addAuthenticator(Class<?> authenticator, APICommand command) {
s_authenticators.put(command.name().toLowerCase(), authenticator);
}

private static synchronized void initAuthenticator() {
s_authenticators = new ConcurrentHashMap<String, Class<?>>();
}

@Override
public List<Class<?>> getCommands() {
List<Class<?>> cmdList = new ArrayList<Class<?>>();
Expand Down
4 changes: 4 additions & 0 deletions utils/src/com/cloud/utils/component/ComponentContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,10 @@ public boolean isInitializeBeans() {
}

public void setInitializeBeans(boolean initializeBeans) {
initInitializeBeans(initializeBeans);
}

private static synchronized void initInitializeBeans(boolean initializeBeans) {
s_initializeBeans = initializeBeans;
}
}

0 comments on commit 764950d

Please sign in to comment.