Author: markt
Date: Fri Dec  1 19:02:44 2017
New Revision: 1816898

URL: http://svn.apache.org/viewvc?rev=1816898&view=rev
Log:
Address a handful of SpotBugs warnings

Modified:
    tomcat/trunk/java/org/apache/jasper/compiler/AntCompiler.java
    tomcat/trunk/java/org/apache/jasper/compiler/Compiler.java
    tomcat/trunk/java/org/apache/jasper/compiler/JDTCompiler.java
    tomcat/trunk/java/org/apache/jasper/resources/LocalStrings.properties
    tomcat/trunk/java/org/apache/juli/OneLineFormatter.java
    tomcat/trunk/res/findbugs/filter-false-positives.xml

Modified: tomcat/trunk/java/org/apache/jasper/compiler/AntCompiler.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/AntCompiler.java?rev=1816898&r1=1816897&r2=1816898&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/compiler/AntCompiler.java (original)
+++ tomcat/trunk/java/org/apache/jasper/compiler/AntCompiler.java Fri Dec  1 
19:02:44 2017
@@ -250,7 +250,10 @@ public class AntCompiler extends Compile
 
         if (!ctxt.keepGenerated()) {
             File javaFile = new File(javaFileName);
-            javaFile.delete();
+            if (!javaFile.delete()) {
+                throw new JasperException(Localizer.getMessage(
+                        "jsp.warning.compiler.javafile.delete.fail", 
javaFile));
+            }
         }
 
         if (be != null) {

Modified: tomcat/trunk/java/org/apache/jasper/compiler/Compiler.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/Compiler.java?rev=1816898&r1=1816897&r2=1816898&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/compiler/Compiler.java (original)
+++ tomcat/trunk/java/org/apache/jasper/compiler/Compiler.java Fri Dec  1 
19:02:44 2017
@@ -384,14 +384,19 @@ public abstract class Compiler {
             Map<String,SmapStratum> smaps = generateJava();
             File javaFile = new File(ctxt.getServletJavaFileName());
             Long jspLastModified = ctxt.getLastModified(ctxt.getJspFile());
-            javaFile.setLastModified(jspLastModified.longValue());
+            if (!javaFile.setLastModified(jspLastModified.longValue())) {
+                throw new 
JasperException(Localizer.getMessage("jsp.error.setLastModified", javaFile));
+            }
             if (compileClass) {
                 generateClass(smaps);
                 // Fix for bugzilla 41606
                 // Set JspServletWrapper.servletClassLastModifiedTime after 
successful compile
                 File targetFile = new File(ctxt.getClassFileName());
                 if (targetFile.exists()) {
-                    targetFile.setLastModified(jspLastModified.longValue());
+                    if 
(!targetFile.setLastModified(jspLastModified.longValue())) {
+                        throw new JasperException(
+                                
Localizer.getMessage("jsp.error.setLastModified", targetFile));
+                    }
                     if (jsw != null) {
                         jsw.setServletClassLastModifiedTime(
                                 jspLastModified.longValue());

Modified: tomcat/trunk/java/org/apache/jasper/compiler/JDTCompiler.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/JDTCompiler.java?rev=1816898&r1=1816897&r2=1816898&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/compiler/JDTCompiler.java (original)
+++ tomcat/trunk/java/org/apache/jasper/compiler/JDTCompiler.java Fri Dec  1 
19:02:44 2017
@@ -449,7 +449,10 @@ public class JDTCompiler extends org.apa
 
         if (!ctxt.keepGenerated()) {
             File javaFile = new File(ctxt.getServletJavaFileName());
-            javaFile.delete();
+            if (!javaFile.delete()) {
+                throw new JasperException(Localizer.getMessage(
+                        "jsp.warning.compiler.javafile.delete.fail", 
javaFile));
+            }
         }
 
         if (!problemList.isEmpty()) {

Modified: tomcat/trunk/java/org/apache/jasper/resources/LocalStrings.properties
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/resources/LocalStrings.properties?rev=1816898&r1=1816897&r2=1816898&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/resources/LocalStrings.properties 
(original)
+++ tomcat/trunk/java/org/apache/jasper/resources/LocalStrings.properties Fri 
Dec  1 19:02:44 2017
@@ -360,6 +360,7 @@ jsp.error.unbalanced.endtag=The end tag
 jsp.error.invalid.bean=The value for the useBean class attribute [{0}] is 
invalid.
 jsp.error.prefix.use_before_dcl=The prefix [{0}] specified in this tag 
directive has been previously used by an action in file [{1}] line [{2}].
 jsp.error.lastModified=Unable to determine last modified date for file [{0}]
+jsp.error.setLastModified=Unable to set last modified date for file [{0}]
 jsp.info.ignoreSetting=Ignored setting for [{0}] of [{1}] because a 
SecurityManager was enabled
 
 jsp.exception=An exception occurred processing [{0}] at line [{1}]

Modified: tomcat/trunk/java/org/apache/juli/OneLineFormatter.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/juli/OneLineFormatter.java?rev=1816898&r1=1816897&r2=1816898&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/juli/OneLineFormatter.java (original)
+++ tomcat/trunk/java/org/apache/juli/OneLineFormatter.java Fri Dec  1 19:02:44 
2017
@@ -43,21 +43,10 @@ public class OneLineFormatter extends Fo
     private static final Object threadMxBeanLock = new Object();
     private static volatile ThreadMXBean threadMxBean = null;
     private static final int THREAD_NAME_CACHE_SIZE = 10000;
-    private static ThreadLocal<LinkedHashMap<Integer,String>> threadNameCache =
-            new ThreadLocal<LinkedHashMap<Integer,String>>() {
-
+    private static ThreadLocal<ThreadNameCache> threadNameCache = new 
ThreadLocal<ThreadNameCache>() {
         @Override
-        protected LinkedHashMap<Integer,String> initialValue() {
-            return new LinkedHashMap<Integer,String>() {
-
-                private static final long serialVersionUID = 1L;
-
-                @Override
-                protected boolean removeEldestEntry(
-                        Entry<Integer, String> eldest) {
-                    return (size() > THREAD_NAME_CACHE_SIZE);
-                }
-            };
+        protected ThreadNameCache initialValue() {
+            return new ThreadNameCache(THREAD_NAME_CACHE_SIZE);
         }
     };
 
@@ -226,4 +215,21 @@ public class OneLineFormatter extends Fo
 
         return result;
     }
+
+
+    private static class ThreadNameCache extends LinkedHashMap<Integer,String> 
{
+
+        private static final long serialVersionUID = 1L;
+
+        private final int cacheSize;
+
+        public ThreadNameCache(int cacheSize) {
+            this.cacheSize = cacheSize;
+        }
+
+        @Override
+        protected boolean removeEldestEntry(Entry<Integer, String> eldest) {
+            return (size() > cacheSize);
+        }
+    }
 }

Modified: tomcat/trunk/res/findbugs/filter-false-positives.xml
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/res/findbugs/filter-false-positives.xml?rev=1816898&r1=1816897&r2=1816898&view=diff
==============================================================================
--- tomcat/trunk/res/findbugs/filter-false-positives.xml (original)
+++ tomcat/trunk/res/findbugs/filter-false-positives.xml Fri Dec  1 19:02:44 
2017
@@ -575,6 +575,12 @@
     <Bug pattern="NP_BOOLEAN_RETURN_NULL"/>
   </Match>
   <Match>
+    <!-- Result is negated because arguments have to be swapped -->
+    <Class name="org.apache.el.lang.ELSupport" />
+    <Method name="compare"/>
+    <Bug pattern="RV_NEGATING_RESULT_OF_COMPARETO"/>
+  </Match>
+  <Match>
     <!-- JspC will not be used under a security manager -->
     <Class name="org.apache.jasper.JspC"/>
     <Method name="initClassLoader"/>
@@ -735,6 +741,11 @@
     <Bug pattern="NP_EQUALS_SHOULD_HANDLE_NULL_ARGUMENT" />
   </Match>
   <Match>
+    <!-- Natural ordering behavoiur is docuemented in Javadoc -->
+    <Class name="org.apache.tomcat.dbcp.pool2.impl.DefaultPooledObject" />
+    <Bug pattern="EQ_COMPARETO_USE_OBJECT_EQUALS" />
+  </Match>
+  <Match>
     <!-- Increment is in sync block so it is safe. Volatile is used so reading
          thread sees latest value.  -->
     <Class name="org.apache.tomcat.dbcp.pool2.impl.DefaultPooledObject" />
@@ -889,6 +900,15 @@
     <Bug code="Dm" />
   </Match>
   <Match>
+    <!-- Deletion failure should never happen -->
+    <Class name="org.apache.tomcat.util.http.fileupload.disk.DiskFileItem"/>
+    <Or>
+      <Method name="delete"/>
+      <Method name="finalize"/>
+    </Or>
+    <Bug pattern="RV_RETURN_VALUE_IGNORED_BAD_PRACTICE" />
+  </Match>
+  <Match>
     <!-- the platform default encoding is a fallback -->
     <Class name="org.apache.tomcat.util.http.fileupload.disk.DiskFileItem"/>
     <Method name="getString"/>



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to