You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by da...@apache.org on 2015/07/17 13:12:38 UTC

[1/2] git commit: updated refs/heads/master to f15eaec

Repository: cloudstack
Updated Branches:
  refs/heads/master 0c72f7743 -> f15eaec25


coverity 1116759: possible null-pointer before indexOf-call move the if-block inside the next, guarded one

Signed-off-by: Daan Hoogland <da...@onecht.net>

This closes #600


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

Branch: refs/heads/master
Commit: f15eaec254efadc12091dfd45af09629a72f9a49
Parents: 8849d50
Author: Daan Hoogland <da...@onecht.net>
Authored: Thu Jul 16 16:51:02 2015 +0200
Committer: Daan Hoogland <da...@onecht.net>
Committed: Fri Jul 17 13:12:26 2015 +0200

----------------------------------------------------------------------
 .../cloudstack/framework/serializer/OnwireClassRegistry.java   | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f15eaec2/framework/ipc/src/org/apache/cloudstack/framework/serializer/OnwireClassRegistry.java
----------------------------------------------------------------------
diff --git a/framework/ipc/src/org/apache/cloudstack/framework/serializer/OnwireClassRegistry.java b/framework/ipc/src/org/apache/cloudstack/framework/serializer/OnwireClassRegistry.java
index 77269f3..872e49c 100644
--- a/framework/ipc/src/org/apache/cloudstack/framework/serializer/OnwireClassRegistry.java
+++ b/framework/ipc/src/org/apache/cloudstack/framework/serializer/OnwireClassRegistry.java
@@ -106,10 +106,10 @@ public class OnwireClassRegistry {
             if (resources != null) {
                 while (resources.hasMoreElements()) {
                     String filePath = resources.nextElement().getFile();
-                    // WINDOWS HACK
-                    if (filePath.indexOf("%20") > 0)
-                        filePath = filePath.replaceAll("%20", " ");
                     if (filePath != null) {
+                        // WINDOWS HACK
+                        if (filePath.indexOf("%20") > 0)
+                            filePath = filePath.replaceAll("%20", " ");
                         if ((filePath.indexOf("!") > 0) && (filePath.indexOf(".jar") > 0)) {
                             String jarPath = filePath.substring(0, filePath.indexOf("!")).substring(filePath.indexOf(":") + 1);
                             // WINDOWS HACK


[2/2] git commit: updated refs/heads/master to f15eaec

Posted by da...@apache.org.
coverity 1116718: neglected jarinputstream when no entry found

Signed-off-by: Daan Hoogland <da...@onecht.net>


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/8849d506
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/8849d506
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/8849d506

Branch: refs/heads/master
Commit: 8849d506cbc18f69d4ca644eb35344a7043ae3f7
Parents: 0c72f77
Author: Daan Hoogland <da...@onecht.net>
Authored: Thu Jul 16 16:48:43 2015 +0200
Committer: Daan Hoogland <da...@onecht.net>
Committed: Fri Jul 17 13:12:26 2015 +0200

----------------------------------------------------------------------
 .../serializer/OnwireClassRegistry.java         | 38 ++++++++++----------
 1 file changed, 18 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8849d506/framework/ipc/src/org/apache/cloudstack/framework/serializer/OnwireClassRegistry.java
----------------------------------------------------------------------
diff --git a/framework/ipc/src/org/apache/cloudstack/framework/serializer/OnwireClassRegistry.java b/framework/ipc/src/org/apache/cloudstack/framework/serializer/OnwireClassRegistry.java
index 46e5965..77269f3 100644
--- a/framework/ipc/src/org/apache/cloudstack/framework/serializer/OnwireClassRegistry.java
+++ b/framework/ipc/src/org/apache/cloudstack/framework/serializer/OnwireClassRegistry.java
@@ -32,7 +32,6 @@ import java.util.Set;
 import java.util.jar.JarEntry;
 import java.util.jar.JarInputStream;
 
-import org.apache.commons.io.IOUtils;
 import org.apache.log4j.Logger;
 
 
@@ -156,28 +155,27 @@ public class OnwireClassRegistry {
 
     static Set<Class<?>> getFromJARFile(String jar, String packageName) throws IOException, ClassNotFoundException {
         Set<Class<?>> classes = new HashSet<Class<?>>();
-        JarInputStream jarFile = new JarInputStream(new FileInputStream(jar));
-        JarEntry jarEntry;
-        do {
-            jarEntry = jarFile.getNextJarEntry();
-            if (jarEntry != null) {
-                String className = jarEntry.getName();
-                if (className.endsWith(".class")) {
-                    className = stripFilenameExtension(className);
-                    if (className.startsWith(packageName)) {
-                        try {
-                            Class<?> clz = Class.forName(className.replace('/', '.'));
-                            classes.add(clz);
-                        } catch (ClassNotFoundException | NoClassDefFoundError e) {
-                            s_logger.warn("Unable to load class from jar file", e);
+        try (JarInputStream jarFile = new JarInputStream(new FileInputStream(jar));) {
+            JarEntry jarEntry;
+            do {
+                jarEntry = jarFile.getNextJarEntry();
+                if (jarEntry != null) {
+                    String className = jarEntry.getName();
+                    if (className.endsWith(".class")) {
+                        className = stripFilenameExtension(className);
+                        if (className.startsWith(packageName)) {
+                            try {
+                                Class<?> clz = Class.forName(className.replace('/', '.'));
+                                classes.add(clz);
+                            } catch (ClassNotFoundException | NoClassDefFoundError e) {
+                                s_logger.warn("Unable to load class from jar file", e);
+                            }
                         }
                     }
                 }
-            }
-        } while (jarEntry != null);
-
-        IOUtils.closeQuietly(jarFile);
-        return classes;
+            } while (jarEntry != null);
+            return classes;
+        }
     }
 
     static String stripFilenameExtension(String file) {