INT-3632: Sonar Improvements

JIRA: https://jira.spring.io/browse/INT-3632

- Use Map.entrySet()
- Double check locking only works when the field(s) are volatile
- Remove unnecessary instanceof tests
This commit is contained in:
Gary Russell
2015-02-10 15:42:31 -05:00
parent 49b4957270
commit 195ee70568
34 changed files with 168 additions and 162 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -107,7 +107,8 @@ public abstract class TestUtils {
ConfigurableListableBeanFactory configurableListableBeanFactory = null;
if (beanFactory instanceof ConfigurableListableBeanFactory) {
configurableListableBeanFactory = (ConfigurableListableBeanFactory) beanFactory;
} else if (beanFactory instanceof GenericApplicationContext) {
}
else if (beanFactory instanceof GenericApplicationContext) {
configurableListableBeanFactory = ((GenericApplicationContext) beanFactory).getBeanFactory();
}
if (bean instanceof BeanNameAware) {
@@ -124,7 +125,7 @@ public abstract class TestUtils {
throw new FatalBeanException("failed to register bean with test context", e);
}
}
configurableListableBeanFactory.registerSingleton(beanName, bean);
configurableListableBeanFactory.registerSingleton(beanName, bean);//NOSONAR false positive
}