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;
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;
- }
+ }
}
}
* - 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;
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;
}
}