Author: markt
Date: Tue Feb 22 16:38:39 2011
New Revision: 1073393
URL: http://svn.apache.org/viewvc?rev=1073393&view=rev
Log:
Test before generating debug log messages
Fix FindBugs issues for File.delete() return value
Modified:
tomcat/trunk/java/org/apache/jasper/compiler/Compiler.java
tomcat/trunk/java/org/apache/jasper/resources/LocalStrings.properties
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=1073393&r1=1073392&r2=1073393&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/compiler/Compiler.java (original)
+++ tomcat/trunk/java/org/apache/jasper/compiler/Compiler.java Tue Feb 22
16:38:39 2011
@@ -271,7 +271,14 @@ public abstract class Compiler {
}
}
// Remove the generated .java file
- new File(javaFileName).delete();
+ File file = new File(javaFileName);
+ if (file.exists()) {
+ if (!file.delete()) {
+ log.warn(Localizer.getMessage(
+ "jsp.warning.compiler.javafile.delete.fail",
+ file.getAbsolutePath()));
+ }
+ }
throw e;
} finally {
if (writer != null) {
@@ -451,7 +458,8 @@ public abstract class Compiler {
}
uc.getInputStream().close();
} catch (Exception e) {
- log.debug("Problem accessing resource. Treat as outdated.", e);
+ if (log.isDebugEnabled())
+ log.debug("Problem accessing resource. Treat as outdated.", e);
return true;
}
@@ -514,7 +522,9 @@ public abstract class Compiler {
return true;
}
} catch (Exception e) {
- log.debug("Problem accessing resource. Treat as outdated.", e);
+ if (log.isDebugEnabled())
+ log.debug("Problem accessing resource. Treat as outdated.",
+ e);
return true;
}
}
@@ -551,7 +561,13 @@ public abstract class Compiler {
File classFile = new File(classFileName);
if (log.isDebugEnabled())
log.debug("Deleting " + classFile);
- classFile.delete();
+ 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
@@ -562,7 +578,13 @@ public abstract class Compiler {
File javaFile = new File(javaFileName);
if (log.isDebugEnabled())
log.debug("Deleting " + javaFile);
- javaFile.delete();
+ if (javaFile.exists()) {
+ if (!javaFile.delete()) {
+ log.warn(Localizer.getMessage(
+ "jsp.warning.compiler.javafile.delete.fail",
+ javaFile.getAbsolutePath()));
+ }
+ }
}
} catch (Exception e) {
// Remove as much as possible, ignore possible exceptions
@@ -576,7 +598,13 @@ public abstract class Compiler {
File classFile = new File(classFileName);
if (log.isDebugEnabled())
log.debug("Deleting " + classFile);
- classFile.delete();
+ 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
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=1073393&r1=1073392&r2=1073393&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/resources/LocalStrings.properties
(original)
+++ tomcat/trunk/java/org/apache/jasper/resources/LocalStrings.properties Tue
Feb 22 16:38:39 2011
@@ -227,6 +227,8 @@ jsp.error.bad_string_char=Cannot extract
jsp.warning.compiler.class.cantcreate=Can't create an instance of specified
compiler plugin class {0} due to {1}. Will default to Sun Java Compiler.
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.javafile.delete.fail=Failed to delete generated Java file
[{0}]
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)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]