You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ta...@apache.org on 2014/10/02 17:51:01 UTC

[1/2] git commit: Fix some issues found with findbugs

Repository: qpid-jms
Updated Branches:
  refs/heads/master 12ca77c42 -> 51da0e5ac


Fix some issues found with findbugs

Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/90490f12
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/90490f12
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/90490f12

Branch: refs/heads/master
Commit: 90490f12e0c84c52428ee55c2d99543c00702926
Parents: 12ca77c
Author: Timothy Bish <ta...@gmail.com>
Authored: Thu Oct 2 11:48:11 2014 -0400
Committer: Timothy Bish <ta...@gmail.com>
Committed: Thu Oct 2 11:48:11 2014 -0400

----------------------------------------------------------------------
 .../org/apache/qpid/jms/util/FactoryFinder.java | 38 ++++++++++----------
 1 file changed, 18 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/90490f12/qpid-jms-client/src/main/java/org/apache/qpid/jms/util/FactoryFinder.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/util/FactoryFinder.java b/qpid-jms-client/src/main/java/org/apache/qpid/jms/util/FactoryFinder.java
index 8060027..baf9c27 100644
--- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/util/FactoryFinder.java
+++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/util/FactoryFinder.java
@@ -113,14 +113,17 @@ public class FactoryFinder<T extends Object> {
     public T newInstance(String key) throws IllegalAccessException, InstantiationException, IOException, ClassNotFoundException, ClassCastException {
         T factory = cachedFactories.get(key);
         if (factory == null) {
-
             Object found = objectFactory.create(path + key);
-            if (found != null && factoryType.isInstance(found)) {
-                factory = factoryType.cast(found);
-                cachedFactories.put(key, factory);
+            if (found != null) {
+                if (factoryType.isInstance(found)) {
+                    factory = factoryType.cast(found);
+                    cachedFactories.putIfAbsent(key, factory);
+                } else {
+                    throw new ClassCastException("Cannot cast " + found.getClass().getName() +
+                        " to " + factoryType.getName());
+                }
             } else {
-                throw new ClassCastException("Cannot cast " + found.getClass().getName() +
-                    " to " + factoryType.getName());
+                throw new ClassNotFoundException("Could not locate factory for class: " + key);
             }
         }
 
@@ -142,27 +145,29 @@ public class FactoryFinder<T extends Object> {
     /**
      * The default implementation of Object factory which works well in stand-alone applications.
      */
-    @SuppressWarnings("rawtypes")
     protected static class StandaloneObjectFactory implements ObjectFactory {
-        final ConcurrentHashMap<String, Class> classMap = new ConcurrentHashMap<String, Class>();
+        final ConcurrentHashMap<String, Class<?>> classMap = new ConcurrentHashMap<String, Class<?>>();
 
         @Override
         public Object create(final String path) throws InstantiationException, IllegalAccessException, ClassNotFoundException, IOException {
-            Class clazz = classMap.get(path);
+            Class<?> clazz = classMap.get(path);
             if (clazz == null) {
                 clazz = loadClass(loadProperties(path));
-                classMap.put(path, clazz);
+                Class<?> previous = classMap.putIfAbsent(path, clazz);
+                if (previous != null) {
+                    clazz = previous;
+                }
             }
             return clazz.newInstance();
         }
 
-        static public Class loadClass(Properties properties) throws ClassNotFoundException, IOException {
+        static public Class<?> loadClass(Properties properties) throws ClassNotFoundException, IOException {
 
             String className = properties.getProperty("class");
             if (className == null) {
                 throw new IOException("Expected property is missing: class");
             }
-            Class clazz = null;
+            Class<?> clazz = null;
             ClassLoader loader = Thread.currentThread().getContextClassLoader();
             if (loader != null) {
                 try {
@@ -192,17 +197,10 @@ public class FactoryFinder<T extends Object> {
             }
 
             // lets load the file
-            BufferedInputStream reader = null;
-            try {
-                reader = new BufferedInputStream(in);
+            try (BufferedInputStream reader = new BufferedInputStream(in)) {
                 Properties properties = new Properties();
                 properties.load(reader);
                 return properties;
-            } finally {
-                try {
-                    reader.close();
-                } catch (Exception e) {
-                }
             }
         }
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[2/2] git commit: Add m2e hint to ignore jacoco-maven-plugin

Posted by ta...@apache.org.
Add m2e hint to ignore jacoco-maven-plugin

Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/51da0e5a
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/51da0e5a
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/51da0e5a

Branch: refs/heads/master
Commit: 51da0e5acf85ae9a96ec1ee2f9886400f4a8da09
Parents: 90490f1
Author: Timothy Bish <ta...@gmail.com>
Authored: Thu Oct 2 11:50:43 2014 -0400
Committer: Timothy Bish <ta...@gmail.com>
Committed: Thu Oct 2 11:50:43 2014 -0400

----------------------------------------------------------------------
 pom.xml | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/51da0e5a/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 474456e..867f51d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -234,6 +234,31 @@
           <artifactId>jacoco-maven-plugin</artifactId>
           <version>${jacoco-plugin-version}</version>
         </plugin>
+        <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
+        <plugin>
+          <groupId>org.eclipse.m2e</groupId>
+          <artifactId>lifecycle-mapping</artifactId>
+          <version>1.0.0</version>
+          <configuration>
+            <lifecycleMappingMetadata>
+              <pluginExecutions>
+                <pluginExecution>
+                  <pluginExecutionFilter>
+                    <groupId>org.jacoco</groupId>
+                    <artifactId>jacoco-maven-plugin</artifactId>
+                    <versionRange>[0.7.2.*,)</versionRange>
+                    <goals>
+                      <goal>prepare-agent</goal>
+                    </goals>
+                  </pluginExecutionFilter>
+                  <action>
+                    <ignore></ignore>
+                  </action>
+                </pluginExecution>
+              </pluginExecutions>
+            </lifecycleMappingMetadata>
+          </configuration>
+        </plugin>
       </plugins>
     </pluginManagement>
     <plugins>


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org