db-jdo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m..@apache.org
Subject [db-jdo] 01/02: JDO-780: Potential NullPointerException in code (patch proviede by Xiangzhe Xu)
Date Sat, 31 Aug 2019 20:23:18 GMT
This is an automated email from the ASF dual-hosted git repository.

mbo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/db-jdo.git

commit f11e17af240f630ea9736d65b93714865f30bef7
Author: Michael Bouschen <mbo@apache.org>
AuthorDate: Sat Aug 31 21:49:47 2019 +0200

    JDO-780: Potential NullPointerException in code (patch proviede by Xiangzhe Xu)
---
 .../java/org/apache/jdo/exectck/Utilities.java     | 36 +++++++---------------
 1 file changed, 11 insertions(+), 25 deletions(-)

diff --git a/exectck/src/main/java/org/apache/jdo/exectck/Utilities.java b/exectck/src/main/java/org/apache/jdo/exectck/Utilities.java
index 8c29d79..fa224e6 100644
--- a/exectck/src/main/java/org/apache/jdo/exectck/Utilities.java
+++ b/exectck/src/main/java/org/apache/jdo/exectck/Utilities.java
@@ -74,14 +74,14 @@ public class Utilities {
     }
 
     public static void printClasspath(ClassLoader loader) {
-
-        //Get the URLs
-        URL[] urls = ((URLClassLoader) loader).getURLs();
-
-        System.out.println(urls.length + " URL(s) for loader: ");
-        for (int i = 0; i < urls.length; i++) {
-            if (urls[i] != null) {
-                System.out.println("    " + urls[i].getFile());
+        if (loader != null && loader instanceof URLClassLoader) {
+            //Get the URLs
+            URL[] urls = ((URLClassLoader) loader).getURLs();
+            System.out.println(urls.length + " URL(s) for loader: ");
+            for (int i = 0; i < urls.length; i++) {
+                if (urls[i] != null) {
+                    System.out.println("    " + urls[i].getFile());
+                }
             }
         }
     }
@@ -89,28 +89,14 @@ public class Utilities {
     public void printClasspath() {
 
         //Get the System Classloader
-        ClassLoader loader = ClassLoader.getSystemClassLoader();
-
-        //Get the URLs
-        URL[] urls = ((URLClassLoader) loader).getURLs();
-
-        for (int i = 0; i < urls.length; i++) {
-            System.out.println("    " + urls[i].getFile());
-        }
+        printClasspath(ClassLoader.getSystemClassLoader());
 
         //Get the System Classloader
-        loader = Thread.currentThread().getContextClassLoader();
-
-        //Get the URLs
-        urls = ((URLClassLoader) loader).getURLs();
-
-        for (int i = 0; i < urls.length; i++) {
-            System.out.println("    " + urls[i].getFile());
-        }
+        printClasspath(Thread.currentThread().getContextClassLoader());
 
     }
 
- static String readFile( String fileName ) throws IOException {
+    static String readFile( String fileName ) throws IOException {
     BufferedReader reader = new BufferedReader( new FileReader (fileName));
     String line  = null;
     StringBuffer stringBuf = new StringBuffer();


Mime
View raw message