You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2009/04/08 14:59:22 UTC
svn commit: r763228 -
/tomcat/trunk/java/org/apache/catalina/session/ManagerBase.java
Author: markt
Date: Wed Apr 8 12:59:21 2009
New Revision: 763228
URL: http://svn.apache.org/viewvc?rev=763228&view=rev
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=46967 and make behaviour consistent when running under a security manager.
Based on a patch provided by Kirk Wolf
Modified:
tomcat/trunk/java/org/apache/catalina/session/ManagerBase.java
Modified: tomcat/trunk/java/org/apache/catalina/session/ManagerBase.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/session/ManagerBase.java?rev=763228&r1=763227&r2=763228&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/session/ManagerBase.java (original)
+++ tomcat/trunk/java/org/apache/catalina/session/ManagerBase.java Wed Apr 8 12:59:21 2009
@@ -223,7 +223,11 @@
private class PrivilegedSetRandomFile implements PrivilegedAction<DataInputStream>{
- public DataInputStream run(){
+ public PrivilegedSetRandomFile(String s) {
+ devRandomSource = s;
+ }
+
+ public DataInputStream run(){
try {
File f=new File( devRandomSource );
if( ! f.exists() ) return null;
@@ -233,8 +237,18 @@
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;
- }
+ }
}
}
@@ -505,10 +519,10 @@
* - 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 (Globals.IS_SECURITY_ENABLED){
- randomIS = AccessController.doPrivileged(new PrivilegedSetRandomFile());
+ randomIS = AccessController.doPrivileged(new PrivilegedSetRandomFile(s));
} else {
try{
devRandomSource=s;
@@ -519,12 +533,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;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org