From 2fe8e48fa81e0aa92261f315a64f97b3f34dcd64 Mon Sep 17 00:00:00 2001 From: schultz Date: Thu, 7 Apr 2011 21:22:12 +0000 Subject: [PATCH] Added warning messages when an exception is thrown while trying to delete files. 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 | 27 +++++++--------------- .../jasper/resources/LocalStrings.properties | 4 +++- 2 files changed, 11 insertions(+), 20 deletions(-) diff --git a/java/org/apache/jasper/compiler/Compiler.java b/java/org/apache/jasper/compiler/Compiler.java index 28b4c2ad0..4b9add497 100644 --- a/java/org/apache/jasper/compiler/Compiler.java +++ b/java/org/apache/jasper/compiler/Compiler.java @@ -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); } } } diff --git a/java/org/apache/jasper/resources/LocalStrings.properties b/java/org/apache/jasper/resources/LocalStrings.properties index d7a82bd2f..33121f8a4 100644 --- a/java/org/apache/jasper/resources/LocalStrings.properties +++ b/java/org/apache/jasper/resources/LocalStrings.properties @@ -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 -- 2.11.0