Code cleanup
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Mon, 7 Mar 2011 14:55:22 +0000 (14:55 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Mon, 7 Mar 2011 14:55:22 +0000 (14:55 +0000)
- remove unused code
- fix FindBugs warnings
- fix Eclipse warnings

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1078798 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/naming/resources/FileDirContext.java
java/org/apache/naming/resources/LocalStrings.properties
java/org/apache/naming/resources/ProxyDirContext.java
java/org/apache/naming/resources/ResourceCache.java
java/org/apache/naming/resources/WARDirContext.java
java/org/apache/naming/resources/jndi/Handler.java [deleted file]

index b8fdc2c..6201c17 100644 (file)
@@ -270,7 +270,10 @@ public class FileDirContext extends BaseDirContext {
 
         File newFile = new File(base, newName);
 
-        file.renameTo(newFile);
+        if (!file.renameTo(newFile)) {
+            throw new NamingException(sm.getString("resources.renameFail",
+                    oldName, newName));
+        }
 
     }
 
index abc1843..4cc7cff 100644 (file)
@@ -22,10 +22,12 @@ 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}
+resources.invalidCache=Unable to create a resource cache of type [{0}]
 resources.notStarted=Resources has not yet been started
 resources.null=Document base cannot be null
 resources.notFound=Resource {0} not found
 resources.path=Context relative path {0} must start with ''/''
+resources.renameFail=Failed to rename [{0}] to [{1}]
 resources.alreadyBound=Name {0} is already bound in this Context
 resources.bindFailed=Bind failed: {0}
 resources.unbindFailed=Unbind failed: {0}
index fa3ca3a..8a85508 100644 (file)
@@ -82,8 +82,8 @@ public class ProxyDirContext implements DirContext {
                     cache = (ResourceCache) 
                         Class.forName(cacheClassName).newInstance();
                 } catch (Exception e) {
-                    //FIXME
-                    e.printStackTrace();
+                    throw new IllegalArgumentException(sm.getString(
+                            "resources.invalidCache", cacheClassName), e);
                 }
                 cache.setCacheMaxSize(baseDirContext.getCacheMaxSize());
                 cacheTTL = baseDirContext.getCacheTTL();
index cc79f41..497db02 100644 (file)
@@ -362,7 +362,7 @@ public class ResourceCache {
 
         int i = 0;
         while (true) {
-            i = (b + a) / 2;
+            i = (b + a) >>> 1;
             int result = name.compareTo(map[i].name);
             if (result > 0) {
                 a = i;
index 82652ba..8106fd1 100644 (file)
@@ -896,7 +896,19 @@ public class WARDirContext extends BaseDirContext {
         public int compareTo(Object o) {
             if (!(o instanceof Entry))
                 return (+1);
-            return (name.compareTo(((Entry) o).getName()));
+            return name.compareTo(((Entry) o).getName());
+        }
+
+        @Override
+        public boolean equals(Object o) {
+            if (!(o instanceof Entry))
+                return false;
+            return name.equals(((Entry) o).getName());
+        }
+        
+        @Override
+        public int hashCode() {
+            return name.hashCode();
         }
 
         public ZipEntry getEntry() {
diff --git a/java/org/apache/naming/resources/jndi/Handler.java b/java/org/apache/naming/resources/jndi/Handler.java
deleted file mode 100644 (file)
index 4167753..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */ 
-
-package org.apache.naming.resources.jndi;
-
-import org.apache.naming.resources.DirContextURLStreamHandler;
-
-/**
- * Stream handler to a JNDI directory context.
- * 
- * @author <a href="mailto:remm@apache.org">Remy Maucherat</a>
- * @version $Revision$
- */
-public class Handler extends DirContextURLStreamHandler {
-    
-    public Handler() {
-        // NOOP
-    }
-}