Author: kkolinko Date: Thu Aug 13 01:07:02 2009 New Revision: 803749 URL: http://svn.apache.org/viewvc?rev=803749&view=rev Log: Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=46967 Better handling of errors when trying to use Manager.randomFile Based on a patch by Kirk Wolf It is backport of rev.777567 from tc6.0
Modified: tomcat/tc5.5.x/trunk/STATUS.txt tomcat/tc5.5.x/trunk/container/catalina/src/share/org/apache/catalina/session/ManagerBase.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=803749&r1=803748&r2=803749&view=diff ============================================================================== --- tomcat/tc5.5.x/trunk/STATUS.txt (original) +++ tomcat/tc5.5.x/trunk/STATUS.txt Thu Aug 13 01:07:02 2009 @@ -68,15 +68,6 @@ +1: kkolinko -1: -* Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=46967 - Better handling of errors when trying to use Manager.randomFile - Based on a patch by Kirk Wolf - Also make behaviour consistent when using a security manager - http://svn.apache.org/viewvc?view=rev&revision=777567 - +1: kkolinko, markt, rjung - -1: - rjung: minus the generics - * https://issues.apache.org/bugzilla/show_bug.cgi?id=47566 Update to NSIS 2.45 http://svn.apache.org/viewvc?rev=797596&view=rev Modified: tomcat/tc5.5.x/trunk/container/catalina/src/share/org/apache/catalina/session/ManagerBase.java URL: http://svn.apache.org/viewvc/tomcat/tc5.5.x/trunk/container/catalina/src/share/org/apache/catalina/session/ManagerBase.java?rev=803749&r1=803748&r2=803749&view=diff ============================================================================== --- tomcat/tc5.5.x/trunk/container/catalina/src/share/org/apache/catalina/session/ManagerBase.java (original) +++ tomcat/tc5.5.x/trunk/container/catalina/src/share/org/apache/catalina/session/ManagerBase.java Thu Aug 13 01:07:02 2009 @@ -219,8 +219,11 @@ private class PrivilegedSetRandomFile implements PrivilegedAction{ - - public Object run(){ + public PrivilegedSetRandomFile(String s) { + devRandomSource = s; + } + + public Object run(){ try { File f=new File( devRandomSource ); if( ! f.exists() ) return null; @@ -230,6 +233,16 @@ log.debug( "Opening " + devRandomSource ); return randomIS; } catch (IOException ex){ + log.warn("Error reading " + devRandomSource, ex); + if (randomIS != null) { + try { + randomIS.close(); + } catch (Exception e) { + log.warn("Failed to close randomIS."); + } + } + devRandomSource = null; + randomIS=null; return null; } } @@ -502,10 +515,11 @@ * - so use it if available. */ public void setRandomFile( String s ) { - // as a hack, you can use a static file - and genarate the same + // as a hack, you can use a static file - and generate the same // session ids ( good for strange debugging ) if (System.getSecurityManager() != null){ - randomIS = (DataInputStream)AccessController.doPrivileged(new PrivilegedSetRandomFile()); + randomIS = (DataInputStream) AccessController + .doPrivileged(new PrivilegedSetRandomFile(s)); } else { try{ devRandomSource=s; @@ -516,12 +530,15 @@ if( log.isDebugEnabled() ) log.debug( "Opening " + devRandomSource ); } catch( IOException ex ) { - try { - randomIS.close(); - } catch (Exception e) { - log.warn("Failed to close randomIS."); + log.warn("Error reading " + devRandomSource, ex); + if (randomIS != null) { + try { + randomIS.close(); + } catch (Exception e) { + log.warn("Failed to close randomIS."); + } } - + devRandomSource = null; randomIS=null; } } 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=803749&r1=803748&r2=803749&view=diff ============================================================================== --- tomcat/tc5.5.x/trunk/container/webapps/docs/changelog.xml (original) +++ tomcat/tc5.5.x/trunk/container/webapps/docs/changelog.xml Thu Aug 13 01:07:02 2009 @@ -55,6 +55,10 @@ ENABLE_CLEAR_REFERENCES. Patch by Curt Arnold. (markt) </fix> <fix> + <bug>46967</bug>: Better handling of errors when trying to use + Manager.randomFile. Based on a patch by Kirk Wolf. (kkolinko) + </fix> + <fix> <bug>47518</bug>: Correct reference in Valve Javadoc that referred to an old method. Patch provided by Christopher Schultz. (markt) </fix> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org