Author: kkolinko
Date: Wed May 26 02:49:51 2010
New Revision: 948296
URL: http://svn.apache.org/viewvc?rev=948296&view=rev
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=48179
Improve processing of TLD cache file:
- log TLD cache reading and writing errors
- if reading a TLD cache fails then continue TLD scanning, instead of quiting
- use finally{} block to close input/output streams when reading/writing the
file
Modified:
tomcat/tc5.5.x/trunk/STATUS.txt
tomcat/tc5.5.x/trunk/container/catalina/src/share/org/apache/catalina/startup/LocalStrings.properties
tomcat/tc5.5.x/trunk/container/catalina/src/share/org/apache/catalina/startup/TldConfig.java
tomcat/tc5.5.x/trunk/container/webapps/docs/changelog.xml
Modified: tomcat/tc5.5.x/trunk/STATUS.txt
URL:
http://svn.apache.org/viewvc/tomcat/tc5.5.x/trunk/STATUS.txt?rev=948296&r1=948295&r2=948296&view=diff
==============================================================================
--- tomcat/tc5.5.x/trunk/STATUS.txt (original)
+++ tomcat/tc5.5.x/trunk/STATUS.txt Wed May 26 02:49:51 2010
@@ -32,12 +32,6 @@ PATCHES PROPOSED TO BACKPORT:
+1: kkolinko, rjung
-1:
-* Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=48179
- Improve processing of TLD cache file
- https://issues.apache.org/bugzilla/attachment.cgi?id=24918
- +1: kkolinko, markt, rjung
- -1:
-
* Remove JSSE13Factory, JSSE13SocketFactory classes,
because
- TC 5.5 runs on JRE 1.4+ and that comes bundled with JSSE 1.4,
Modified:
tomcat/tc5.5.x/trunk/container/catalina/src/share/org/apache/catalina/startup/LocalStrings.properties
URL:
http://svn.apache.org/viewvc/tomcat/tc5.5.x/trunk/container/catalina/src/share/org/apache/catalina/startup/LocalStrings.properties?rev=948296&r1=948295&r2=948296&view=diff
==============================================================================
---
tomcat/tc5.5.x/trunk/container/catalina/src/share/org/apache/catalina/startup/LocalStrings.properties
(original)
+++
tomcat/tc5.5.x/trunk/container/catalina/src/share/org/apache/catalina/startup/LocalStrings.properties
Wed May 26 02:49:51 2010
@@ -91,7 +91,9 @@ hostConfig.undeploy=Undeploying context
hostConfig.undeploy.error=Error undeploying web application at context path {0}
hostConfig.undeploying=Undeploying deployed web applications
tldConfig.cce=Lifecycle event data object {0} is not a Context
-tldConfig.execute=Error processing TLD files for context path {0}
+tldConfig.execute=Error processing TLD files for context path [{0}]
+tldConfig.cache.read=Error trying to read a TLD cache file for context path
[{0}]
+tldConfig.cache.write=Error trying to write a TLD cache file for context path
[{0}]
userConfig.database=Exception loading user database
userConfig.deploy=Deploying web application for user {0}
userConfig.deploying=Deploying user web applications
Modified:
tomcat/tc5.5.x/trunk/container/catalina/src/share/org/apache/catalina/startup/TldConfig.java
URL:
http://svn.apache.org/viewvc/tomcat/tc5.5.x/trunk/container/catalina/src/share/org/apache/catalina/startup/TldConfig.java?rev=948296&r1=948295&r2=948296&view=diff
==============================================================================
---
tomcat/tc5.5.x/trunk/container/catalina/src/share/org/apache/catalina/startup/TldConfig.java
(original)
+++
tomcat/tc5.5.x/trunk/container/catalina/src/share/org/apache/catalina/startup/TldConfig.java
Wed May 26 02:49:51 2010
@@ -274,8 +274,8 @@ public final class TldConfig implements
// find the cache
if( tldCache!= null && tldCache.exists()) {
// just read it...
- processCache(tldCache);
- return;
+ if (processCache(tldCache))
+ return;
}
}
@@ -290,8 +290,8 @@ public final class TldConfig implements
if (tldCache != null && tldCache.exists()) {
long lastModified = getLastModified(resourcePaths, jarPaths);
if (lastModified < tldCache.lastModified()) {
- processCache(tldCache);
- return;
+ if (processCache(tldCache))
+ return;
}
}
@@ -316,13 +316,29 @@ public final class TldConfig implements
if( tldCache!= null ) {
log.debug( "Saving tld cache: " + tldCache + " " + list.length);
+ FileOutputStream out = null;
try {
- FileOutputStream out=new FileOutputStream(tldCache);
+ out=new FileOutputStream(tldCache);
ObjectOutputStream oos=new ObjectOutputStream( out );
oos.writeObject( list );
oos.close();
+ out = null;
} catch( IOException ex ) {
- ex.printStackTrace();
+ log.warn(sm.getString("tldConfig.cache.write", context
+ .getPath()), ex);
+ } finally {
+ if (out != null) {
+ try {
+ out.close();
+ } catch (Exception ignored) {
+ // Do nothing
+ }
+ try {
+ tldCache.delete();
+ } catch (Exception ignored) {
+ // Do nothing
+ }
+ }
}
}
@@ -385,10 +401,11 @@ public final class TldConfig implements
return lastModified;
}
- private void processCache(File tldCache ) throws IOException {
+ private boolean processCache(File tldCache ) throws IOException {
// read the cache and return;
+ FileInputStream in = null;
try {
- FileInputStream in=new FileInputStream(tldCache);
+ in =new FileInputStream(tldCache);
ObjectInputStream ois=new ObjectInputStream( in );
String list[]=(String [])ois.readObject();
if( log.isDebugEnabled() )
@@ -397,8 +414,25 @@ public final class TldConfig implements
context.addApplicationListener(list[i]);
}
ois.close();
- } catch( ClassNotFoundException ex ) {
- ex.printStackTrace();
+ in = null;
+ return true;
+ } catch( Exception ex ) {
+ log.warn(sm.getString("tldConfig.cache.read", context
+ .getPath()), ex);
+ return false;
+ } finally {
+ if (in != null) {
+ try {
+ in.close();
+ } catch (Exception ignored) {
+ // Do nothing
+ }
+ try {
+ tldCache.delete();
+ } catch (Exception ignored) {
+ // Do nothing
+ }
+ }
}
}
Modified: tomcat/tc5.5.x/trunk/container/webapps/docs/changelog.xml
URL:
http://svn.apache.org/viewvc/tomcat/tc5.5.x/trunk/container/webapps/docs/changelog.xml?rev=948296&r1=948295&r2=948296&view=diff
==============================================================================
--- tomcat/tc5.5.x/trunk/container/webapps/docs/changelog.xml (original)
+++ tomcat/tc5.5.x/trunk/container/webapps/docs/changelog.xml Wed May 26
02:49:51 2010
@@ -76,6 +76,10 @@
<bug>47774</bug>: Ensure web application class loader is used when
calling session listeners. (kfujino)
</fix>
+ <update>
+ <bug>48179</bug>: Improve error handling when reading or writing
+ TLD cache file ("tldCache.ser"). (kkolinko)
+ </update>
<fix>
Ensure all required i18n messages are present for the APR/native
Listener. (kkolinko)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]