Added warning messages when an exception is thrown while trying to delete files.
authorschultz <schultz@13f79535-47bb-0310-9956-ffa450edef68>
Thu, 7 Apr 2011 21:22:12 +0000 (21:22 +0000)
committerschultz <schultz@13f79535-47bb-0310-9956-ffa450edef68>
Thu, 7 Apr 2011 21:22:12 +0000 (21:22 +0000)
Replaced duplicate code in removeGeneratedFiles with a call to removeGeneratedClassFiles.

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

java/org/apache/jasper/compiler/Compiler.java
java/org/apache/jasper/resources/LocalStrings.properties

index 28b4c2a..4b9add4 100644 (file)
@@ -555,23 +555,8 @@ public abstract class Compiler {
      * Remove generated files
      */
     public void removeGeneratedFiles() {
-        try {
-            String classFileName = ctxt.getClassFileName();
-            if (classFileName != null) {
-                File classFile = new File(classFileName);
-                if (log.isDebugEnabled())
-                    log.debug("Deleting " + classFile);
-                if (classFile.exists()) {
-                    if (!classFile.delete()) {
-                        log.warn(Localizer.getMessage(
-                                "jsp.warning.compiler.classfile.delete.fail",
-                                classFile.getAbsolutePath()));
-                    }
-                }
-            }
-        } catch (Exception e) {
-            // Remove as much as possible, ignore possible exceptions
-        }
+        removeGeneratedClassFiles();
+
         try {
             String javaFileName = ctxt.getServletJavaFileName();
             if (javaFileName != null) {
@@ -587,7 +572,9 @@ public abstract class Compiler {
                 }
             }
         } catch (Exception e) {
-            // Remove as much as possible, ignore possible exceptions
+            // Remove as much as possible, log possible exceptions
+            log.warn(Localizer.getMessage("jsp.warning.compiler.classfile.delete.fail.unknown"),
+                     e);
         }
     }
 
@@ -607,7 +594,9 @@ public abstract class Compiler {
                 }
             }
         } catch (Exception e) {
-            // Remove as much as possible, ignore possible exceptions
+            // Remove as much as possible, log possible exceptions
+            log.warn(Localizer.getMessage("jsp.warning.compiler.classfile.delete.fail.unknown"),
+                     e);
         }
     }
 }
index d7a82bd..33121f8 100644 (file)
@@ -228,7 +228,9 @@ jsp.warning.compiler.class.cantcreate=Can't create an instance of specified comp
 jsp.warning.compiler.class.notfound=Specified compiler plugin class {0} not found. Will default to Sun Java Compiler.
 jsp.warning.compiler.path.notfound=Specified compiler path {0} not found. Will default to system PATH.
 jsp.warning.compiler.classfile.delete.fail=Failed to delete generated class file [{0}] 
+jsp.warning.compiler.classfile.delete.fail.unknown=Failed to delete generated class file(s)
 jsp.warning.compiler.javafile.delete.fail=Failed to delete generated Java file [{0}] 
+jsp.warning.compiler.javafile.delete.fail.unknown=Failed to delete generated Java file(s)
 jsp.error.jspc.uriroot_not_dir=The -uriroot option must specify a pre-existing directory
 jsp.error.jspc.missingTarget=Missing target: Must specify -webapp or -uriroot, or one or more JSP pages
 jsp.error.jspc.no_uriroot=The uriroot is not specified and cannot be located with the specified JSP file(s)
@@ -484,4 +486,4 @@ jsp.message.jsp_removed_excess=Removing excess JSP for path [{0}] from queue of
 jsp.message.jsp_removed_idle=Removing idle JSP for path [{0}] in context [{1}] after {2} seconds");
 jsp.message.jsp_unload_check=Checking JSPs for unload in context [{0}], JSP count: {1} queue length: {2}
 
-xmlParser.skipBomFail=Failed to skip BOM when parsing XML input stream
\ No newline at end of file
+xmlParser.skipBomFail=Failed to skip BOM when parsing XML input stream