mirror of https://github.com/apache/lucene.git
SOLR-3187: SystemInfoHandler leaks filehandles
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1297423 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d7ab78593b
commit
4ebf04948b
|
@ -543,6 +543,8 @@ Optimizations
|
|||
|
||||
Bug Fixes
|
||||
----------------------
|
||||
* SOLR-3187 SystemInfoHandler leaks filehandles (siren)
|
||||
|
||||
* SOLR-2912: Fixed File descriptor leak in ShowFileRequestHandler (Michael Ryan, shalin)
|
||||
|
||||
* SOLR-2819: Improved speed of parsing hex entities in HTMLStripCharFilter
|
||||
|
|
|
@ -142,11 +142,12 @@ public class SystemInfoHandler extends RequestHandlerBase
|
|||
if( !os.getName().toLowerCase(Locale.ENGLISH).startsWith( "windows" ) ) {
|
||||
// Try some command line things
|
||||
info.add( "uname", execute( "uname -a" ) );
|
||||
info.add( "ulimit", execute( "ulimit -n" ) );
|
||||
info.add( "uptime", execute( "uptime" ) );
|
||||
}
|
||||
}
|
||||
catch( Throwable ex ) {} // ignore
|
||||
catch( Throwable ex ) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
|
@ -181,21 +182,24 @@ public class SystemInfoHandler extends RequestHandlerBase
|
|||
private static String execute( String cmd )
|
||||
{
|
||||
DataInputStream in = null;
|
||||
BufferedReader reader = null;
|
||||
Process process = null;
|
||||
|
||||
try {
|
||||
Process process = Runtime.getRuntime().exec(cmd);
|
||||
process = Runtime.getRuntime().exec(cmd);
|
||||
in = new DataInputStream( process.getInputStream() );
|
||||
// use default charset from locale here, because the command invoked also uses the default locale:
|
||||
return IOUtils.toString( in );
|
||||
return IOUtils.toString(in);
|
||||
}
|
||||
catch( Exception ex ) {
|
||||
// ignore - log.warn("Error executing command", ex);
|
||||
return "(error executing: " + cmd + ")";
|
||||
}
|
||||
finally {
|
||||
IOUtils.closeQuietly( reader );
|
||||
IOUtils.closeQuietly( in );
|
||||
if (process != null) {
|
||||
IOUtils.closeQuietly( process.getOutputStream() );
|
||||
IOUtils.closeQuietly( process.getInputStream() );
|
||||
IOUtils.closeQuietly( process.getErrorStream() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue