Code clean-up. Fix Eclipse warnings. Implement TODOs.
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 23 Jul 2010 10:19:32 +0000 (10:19 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 23 Jul 2010 10:19:32 +0000 (10:19 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@967021 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/naming/resources/BaseDirContext.java
java/org/apache/naming/resources/LocalStrings.properties

index cb7901b..1cd8923 100644 (file)
@@ -61,9 +61,6 @@ public abstract class BaseDirContext implements DirContext {
     private static final org.apache.juli.logging.Log log=
         org.apache.juli.logging.LogFactory.getLog( BaseDirContext.class );
 
-    // -------------------------------------------------------------- Constants
-
-
     // ----------------------------------------------------------- Constructors
 
 
@@ -157,18 +154,25 @@ public abstract class BaseDirContext implements DirContext {
      * a requested resource can not be found in the main context.
      */
     public void addResourcesJar(URL url) {
+        JarFile jarFile = null; 
         try {
             JarURLConnection conn = (JarURLConnection) url.openConnection();
-            JarFile jarFile = conn.getJarFile();   
+            jarFile = conn.getJarFile();   
             ZipEntry entry = jarFile.getEntry("/");
             WARDirContext warDirContext = new WARDirContext(jarFile,
                     new WARDirContext.Entry("/", entry));
             warDirContext.loadEntries();
             altDirContexts.add(warDirContext);
         } catch (IOException ioe) {
-            // TODO: Log failure
+            log.warn(sm.getString("resources.addResourcesJarFail", url), ioe);
         } finally {
-            // TODO: Clean up
+            if (jarFile != null) {
+                try {
+                    jarFile.close();
+                } catch (IOException e) {
+                    // Ignore
+                }
+            }
         }
     }
     
@@ -868,8 +872,8 @@ public abstract class BaseDirContext implements DirContext {
      */
     public Name composeName(Name name, Name prefix)
         throws NamingException {
-        prefix = (Name) prefix.clone();
-        return prefix.addAll(name);
+        Name clone = (Name) prefix.clone();
+        return clone.addAll(name);
     }
 
 
index 4e1a37d..abc1843 100644 (file)
@@ -18,6 +18,7 @@ fileResources.listingNull=Could not get dir listing for {0}
 warResources.notWar=Doc base must point to a WAR file
 warResources.invalidWar=Invalid or unreadable WAR file : {0}
 jarResources.syntax=Document base {0} must start with ''jar:'' and end with ''!/''
+resources.addResourcesJarFail=Failed to add resources jar [{0}]
 resources.alreadyStarted=Resources has already been started
 resources.connect=Cannot connect to document base {0}
 resources.input=Cannot create input stream for resource {0}