Author: peter_firmstone Date: Tue Dec 13 13:20:41 2011 New Revision: 1213675
URL: http://svn.apache.org/viewvc?rev=1213675&view=rev Log: River-401 Fix Null Pointer Modified: river/jtsk/trunk/src/net/jini/loader/pref/PreferredClassProvider.java Modified: river/jtsk/trunk/src/net/jini/loader/pref/PreferredClassProvider.java URL: http://svn.apache.org/viewvc/river/jtsk/trunk/src/net/jini/loader/pref/PreferredClassProvider.java?rev=1213675&r1=1213674&r2=1213675&view=diff ============================================================================== --- river/jtsk/trunk/src/net/jini/loader/pref/PreferredClassProvider.java (original) +++ river/jtsk/trunk/src/net/jini/loader/pref/PreferredClassProvider.java Tue Dec 13 13:20:41 2011 @@ -486,14 +486,10 @@ public class PreferredClassProvider exte defaultLoader }); } - + + // throws MalformedURLException URI[] codebaseURIs = pathToURIs(codebase); // may be null - // throws MalformedURLException - int l = codebaseURIs.length; - URL[] codebaseURLs = new URL[l]; - for (int i = 0; i < l; i++ ){ - codebaseURLs[i] = asURL(codebaseURIs[i]); // throws MalformedURLException - } + URL[] codebaseURLs = asURL(codebaseURIs); // throws MalformedURLException /* * Process array class names. @@ -899,13 +895,9 @@ public class PreferredClassProvider exte throws MalformedURLException { checkInitialized(); + // throws MalformedURLException URI[] codebaseURIs = pathToURIs(codebase); // may be null - // throws MalformedURLException - int l = codebaseURIs.length; - URL[] codebaseURLs = new URL[l]; - for (int i = 0; i < l; i++ ){ - codebaseURLs[i] = asURL(codebaseURIs[i]); // throws MalformedURLException - } + URL[] codebaseURLs = asURL(codebaseURIs); // throws MalformedURLException ClassLoader contextLoader = getRMIContextClassLoader(); SecurityManager sm = System.getSecurityManager(); @@ -1079,11 +1071,7 @@ public class PreferredClassProvider exte } // throws MalformedURLException containing URISyntaxException message URI[] codebaseURIs = pathToURIs(codebase); // may be null - int l = codebaseURIs.length; - URL[] codebaseURLs = new URL[l]; - for (int i = 0; i < l; i++ ){ - codebaseURLs[i] = asURL(codebaseURIs[i]); // throws MalformedURLException - } + URL[] codebaseURLs = asURL(codebaseURIs); /* * Determine the codebase loader. @@ -1445,12 +1433,17 @@ public class PreferredClassProvider exte return urls; } - /* Converts a URI to an URL. + /** Converts URI[] to URL[]. */ - private URL asURL(URI uri) throws MalformedURLException{ - if (uri == null) throw new NullPointerException("URI cannot be null"); + private URL[] asURL(URI[] uris) throws MalformedURLException{ + if (uris == null) return null; try { - return uri.toURL(); + int l = uris.length; + URL[] urls = new URL[l]; + for (int i = 0; i < l; i++ ){ + urls[i] = uris[i] == null ? null : uris[i].toURL(); // throws MalformedURLException + } + return urls; } catch (IllegalArgumentException ex){ throw new MalformedURLException(ex.getMessage()); }
