You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2015/09/24 15:39:52 UTC

[2/2] camel git commit: No need for sync in that guice unit test as reported by some code scanner tools.

No need for sync in that guice unit test as reported by some code scanner tools.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/92c4a815
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/92c4a815
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/92c4a815

Branch: refs/heads/master
Commit: 92c4a815b273e8d76dc3da539aa766a397fd02d5
Parents: 21b72c0
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Sep 24 15:41:20 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Sep 24 15:41:20 2015 +0200

----------------------------------------------------------------------
 .../apache/camel/guice/testing/InjectorManager.java | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/92c4a815/components/camel-guice/src/test/java/org/apache/camel/guice/testing/InjectorManager.java
----------------------------------------------------------------------
diff --git a/components/camel-guice/src/test/java/org/apache/camel/guice/testing/InjectorManager.java b/components/camel-guice/src/test/java/org/apache/camel/guice/testing/InjectorManager.java
index a01a5d3..25d0129 100644
--- a/components/camel-guice/src/test/java/org/apache/camel/guice/testing/InjectorManager.java
+++ b/components/camel-guice/src/test/java/org/apache/camel/guice/testing/InjectorManager.java
@@ -15,6 +15,7 @@
  * limitations under the License.
  */
 package org.apache.camel.guice.testing;
+
 import java.lang.reflect.Modifier;
 import java.util.Map;
 import java.util.Map.Entry;
@@ -36,7 +37,6 @@ import org.apache.camel.guice.util.CloseableScope;
 
 /**
  * Used to manage the injectors for the various injection points
- * 
  */
 public class InjectorManager {
     private static final String NESTED_MODULE_CLASS = "TestModule";
@@ -97,14 +97,11 @@ public class InjectorManager {
         Class<? extends Object> testType = test.getClass();
         moduleType = getModuleForTestClass(testType);
 
-        Injector classInjector;
-        synchronized (injectors) {
-            classInjector = injectors.get(moduleType);
-            if (classInjector == null) {
-                classInjector = createInjector(moduleType);
-                Preconditions.checkNotNull(classInjector, "classInjector");
-                injectors.put(moduleType, classInjector);
-            }
+        Injector classInjector = injectors.get(moduleType);
+        if (classInjector == null) {
+            classInjector = createInjector(moduleType);
+            Preconditions.checkNotNull(classInjector, "classInjector");
+            injectors.put(moduleType, classInjector);
         }
         injectors.put(testType, classInjector);
 
@@ -147,7 +144,6 @@ public class InjectorManager {
         CloseErrors errors = new CloseErrorsImpl(this);
         Set<Entry<Object, Injector>> entries = injectors.entrySet();
         for (Entry<Object, Injector> entry : entries) {
-            // Object key = entry.getKey();
             Injector injector = entry.getValue();
             Injectors.close(injector, errors);
         }