This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 7.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 420c2b65326d416c366b58723bd1cdf224e6eea9
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Wed Nov 13 22:49:19 2019 +0000

    SpotBugs fixes (incomplete) for Jasper and better align with 8.5.x
---
 java/org/apache/jasper/compiler/AntCompiler.java | 5 ++++-
 java/org/apache/jasper/compiler/Compiler.java    | 6 +++++-
 java/org/apache/jasper/compiler/JDTCompiler.java | 8 ++++----
 3 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/java/org/apache/jasper/compiler/AntCompiler.java 
b/java/org/apache/jasper/compiler/AntCompiler.java
index 7ee28fc..2dcd528 100644
--- a/java/org/apache/jasper/compiler/AntCompiler.java
+++ b/java/org/apache/jasper/compiler/AntCompiler.java
@@ -249,7 +249,10 @@ public class AntCompiler extends Compiler {
 
         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) {
diff --git a/java/org/apache/jasper/compiler/Compiler.java 
b/java/org/apache/jasper/compiler/Compiler.java
index 3ce7e08..4f6e9c3 100644
--- a/java/org/apache/jasper/compiler/Compiler.java
+++ b/java/org/apache/jasper/compiler/Compiler.java
@@ -68,6 +68,7 @@ public abstract class Compiler {
 
     protected Node.Nodes pageNodes;
 
+
     // ------------------------------------------------------------ Constructor
 
     public void init(JspCompilationContext ctxt, JspServletWrapper jsw) {
@@ -76,6 +77,7 @@ public abstract class Compiler {
         this.options = ctxt.getOptions();
     }
 
+
     // --------------------------------------------------------- Public Methods
 
     /**
@@ -89,11 +91,13 @@ public abstract class Compiler {
         return this.pageNodes;
     }
 
+
     /**
      * Compile the jsp file into equivalent servlet in .java file
      *
      * @return a smap for the current JSP page, if one is generated, null
      *         otherwise
+     * @throws Exception Error generating Java source
      */
     protected String[] generateJava() throws Exception {
 
@@ -263,7 +267,7 @@ public abstract class Compiler {
                         + " generate=" + (t4 - t3) + " validate=" + (t2 - t1));
             }
 
-        } catch (Exception e) {
+        } catch (RuntimeException e) {
             if (writer != null) {
                 try {
                     writer.close();
diff --git a/java/org/apache/jasper/compiler/JDTCompiler.java 
b/java/org/apache/jasper/compiler/JDTCompiler.java
index 8124bd0..91de3dc 100644
--- a/java/org/apache/jasper/compiler/JDTCompiler.java
+++ b/java/org/apache/jasper/compiler/JDTCompiler.java
@@ -581,7 +581,10 @@ public class JDTCompiler extends 
org.apache.jasper.compiler.Compiler {
 
         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()) {
@@ -604,8 +607,5 @@ public class JDTCompiler extends 
org.apache.jasper.compiler.Compiler {
         if (! options.isSmapSuppressed()) {
             SmapUtil.installSmap(smap);
         }
-
     }
-
-
 }


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

Reply via email to