From: markt Date: Mon, 7 Mar 2011 14:55:22 +0000 (+0000) Subject: Code cleanup X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=ba2d26c3ffeb5bafe4c67611090fef33fc3f0211;p=tomcat7.0 Code cleanup - 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 --- diff --git a/java/org/apache/naming/resources/FileDirContext.java b/java/org/apache/naming/resources/FileDirContext.java index b8fdc2c37..6201c17c9 100644 --- a/java/org/apache/naming/resources/FileDirContext.java +++ b/java/org/apache/naming/resources/FileDirContext.java @@ -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)); + } } diff --git a/java/org/apache/naming/resources/LocalStrings.properties b/java/org/apache/naming/resources/LocalStrings.properties index abc1843c8..4cc7cff33 100644 --- a/java/org/apache/naming/resources/LocalStrings.properties +++ b/java/org/apache/naming/resources/LocalStrings.properties @@ -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} diff --git a/java/org/apache/naming/resources/ProxyDirContext.java b/java/org/apache/naming/resources/ProxyDirContext.java index fa3ca3a11..8a8550813 100644 --- a/java/org/apache/naming/resources/ProxyDirContext.java +++ b/java/org/apache/naming/resources/ProxyDirContext.java @@ -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(); diff --git a/java/org/apache/naming/resources/ResourceCache.java b/java/org/apache/naming/resources/ResourceCache.java index cc79f41d7..497db0250 100644 --- a/java/org/apache/naming/resources/ResourceCache.java +++ b/java/org/apache/naming/resources/ResourceCache.java @@ -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; diff --git a/java/org/apache/naming/resources/WARDirContext.java b/java/org/apache/naming/resources/WARDirContext.java index 82652ba2f..8106fd1a7 100644 --- a/java/org/apache/naming/resources/WARDirContext.java +++ b/java/org/apache/naming/resources/WARDirContext.java @@ -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 index 41677532f..000000000 --- a/java/org/apache/naming/resources/jndi/Handler.java +++ /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 Remy Maucherat - * @version $Revision$ - */ -public class Handler extends DirContextURLStreamHandler { - - public Handler() { - // NOOP - } -}