From 3b9353650246a6c5dfe98a38f323292634001446 Mon Sep 17 00:00:00 2001 From: markt Date: Tue, 18 Jan 2011 18:57:45 +0000 Subject: [PATCH] Fix the last of the high priority FindBugs warnings git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1060538 13f79535-47bb-0310-9956-ffa450edef68 --- java/org/apache/jasper/JspC.java | 22 ++++++++------- .../jasper/resources/LocalStrings.properties | 1 + .../naming/factory/webservices/ServiceProxy.java | 7 +++-- java/org/apache/tomcat/util/buf/StringCache.java | 8 +++--- res/findbugs/filter-false-positives.xml | 32 +++++++++++++++++++++- 5 files changed, 53 insertions(+), 17 deletions(-) diff --git a/java/org/apache/jasper/JspC.java b/java/org/apache/jasper/JspC.java index 0300a5109..22e43de2a 100644 --- a/java/org/apache/jasper/JspC.java +++ b/java/org/apache/jasper/JspC.java @@ -151,7 +151,6 @@ public class JspC implements Options { insertBefore.add(""); } - protected static int die; protected String classPath = null; protected URLClassLoader loader = null; protected boolean trimSpaces = false; @@ -251,8 +250,9 @@ public class JspC implements Options { if (arg.length == 0) { System.out.println(Localizer.getMessage("jspc.usage")); } else { + JspC jspc = null; try { - JspC jspc = new JspC(); + jspc = new JspC(); jspc.setArgs(arg); if (jspc.helpNeeded) { System.out.println(Localizer.getMessage("jspc.usage")); @@ -261,8 +261,8 @@ public class JspC implements Options { } } catch (JasperException je) { System.err.println(je); - if (die != NO_DIE_LEVEL) { - System.exit(die); + if (jspc != null && jspc.dieLevel != NO_DIE_LEVEL) { + System.exit(jspc.dieLevel); } } } @@ -279,7 +279,6 @@ public class JspC implements Options { String tok; dieLevel = NO_DIE_LEVEL; - die = dieLevel; while ((tok = nextArg()) != null) { if (tok.equals(SWITCH_VERBOSE)) { @@ -341,7 +340,6 @@ public class JspC implements Options { } catch (NumberFormatException nfe) { dieLevel = DEFAULT_DIE_LEVEL; } - die = dieLevel; } else if (tok.equals(SWITCH_HELP)) { helpNeeded = true; } else if (tok.equals(SWITCH_POOLING)) { @@ -804,8 +802,8 @@ public class JspC implements Options { * includes. */ public void setUriroot( String s ) { - if( s==null ) { - uriRoot = s; + if (s == null) { + uriRoot = null; return; } try { @@ -1097,8 +1095,12 @@ public class JspC implements Options { fis.close(); fos.close(); - webXml2.delete(); - (new File(webxmlFile)).delete(); + if(!webXml2.delete() && log.isDebugEnabled()) + log.debug(Localizer.getMessage("jspc.delete.fail", + webXml2.toString())); + + if (!(new File(webxmlFile)).delete() && log.isDebugEnabled()) + log.debug(Localizer.getMessage("jspc.delete.fail", webxmlFile)); } diff --git a/java/org/apache/jasper/resources/LocalStrings.properties b/java/org/apache/jasper/resources/LocalStrings.properties index cae25290a..e8088ddae 100644 --- a/java/org/apache/jasper/resources/LocalStrings.properties +++ b/java/org/apache/jasper/resources/LocalStrings.properties @@ -296,6 +296,7 @@ jspc.error.jasperException=error-the file ''{0}'' generated the following parse jspc.error.generalException=ERROR-the file ''{0}'' generated the following general exception: jspc.error.fileDoesNotExist=The file argument ''{0}'' does not exist jspc.error.emptyWebApp=-webapp requires a trailing file argument +jspc.delete.fail=Failed to delete file [{0}] jsp.error.library.invalid=JSP page is invalid according to library {0}: {1} jsp.error.tlvclass.instantiation=Failed to load or instantiate TagLibraryValidator class: {0} jsp.error.tlv.invalid.page=Validation error messages from TagLibraryValidator for {0} in {1} diff --git a/java/org/apache/naming/factory/webservices/ServiceProxy.java b/java/org/apache/naming/factory/webservices/ServiceProxy.java index 2bf07a6c8..5d2b212a3 100644 --- a/java/org/apache/naming/factory/webservices/ServiceProxy.java +++ b/java/org/apache/naming/factory/webservices/ServiceProxy.java @@ -75,9 +75,11 @@ public class ServiceProxy } /** - * @see java.lang.reflect.InvocationHandler#invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[]) + * @see InvocationHandler#invoke(Object, Method, Object[]) */ - public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { + @Override + public Object invoke(Object proxy, Method method, Object[] args) + throws Throwable { if (portQNameClass.equals(method)) { return getProxyPortQNameClass(args); @@ -99,6 +101,7 @@ public class ServiceProxy * @return Returns the correct Port * @throws ServiceException if port's QName is an unknown Port (not defined in WSDL). */ + @SuppressWarnings("unchecked") private Object getProxyPortQNameClass(Object[] args) throws ServiceException { QName name = (QName) args[0]; diff --git a/java/org/apache/tomcat/util/buf/StringCache.java b/java/org/apache/tomcat/util/buf/StringCache.java index ce74e2b61..23cd270b6 100644 --- a/java/org/apache/tomcat/util/buf/StringCache.java +++ b/java/org/apache/tomcat/util/buf/StringCache.java @@ -236,7 +236,7 @@ public class StringCache { for (Entry item : bcStats.entrySet()) { ByteEntry entry = item.getKey(); int[] countA = item.getValue(); - Integer count = new Integer(countA[0]); + Integer count = Integer.valueOf(countA[0]); // Add to the list for that count ArrayList list = tempMap.get(count); if (list == null) { @@ -353,7 +353,7 @@ public class StringCache { for (Entry item : ccStats.entrySet()) { CharEntry entry = item.getKey(); int[] countA = item.getValue(); - Integer count = new Integer(countA[0]); + Integer count = Integer.valueOf(countA[0]); // Add to the list for that count ArrayList list = tempMap.get(count); if (list == null) { @@ -518,7 +518,7 @@ public class StringCache { int i = 0; while (true) { - i = (b + a) / 2; + i = (b + a) >>> 1; int result = compare(name, array[i].name); if (result == 1) { a = i; @@ -612,7 +612,7 @@ public class StringCache { int i = 0; while (true) { - i = (b + a) / 2; + i = (b + a) >>> 1; int result = compare(name, array[i].name); if (result == 1) { a = i; diff --git a/res/findbugs/filter-false-positives.xml b/res/findbugs/filter-false-positives.xml index 1ab467c60..95969b360 100644 --- a/res/findbugs/filter-false-positives.xml +++ b/res/findbugs/filter-false-positives.xml @@ -17,6 +17,11 @@ + + + + + @@ -28,7 +33,7 @@ - + @@ -60,6 +65,18 @@ + + + + + + + + + + + + @@ -67,6 +84,13 @@ + + + + + + @@ -93,6 +117,12 @@ + + + + + + -- 2.11.0