You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by si...@apache.org on 2012/03/06 12:08:14 UTC
svn commit: r1297423 - in /lucene/dev/trunk/solr: CHANGES.txt
core/src/java/org/apache/solr/handler/admin/SystemInfoHandler.java
Author: siren
Date: Tue Mar 6 11:08:14 2012
New Revision: 1297423
URL: http://svn.apache.org/viewvc?rev=1297423&view=rev
Log:
SOLR-3187: SystemInfoHandler leaks filehandles
Modified:
lucene/dev/trunk/solr/CHANGES.txt
lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/admin/SystemInfoHandler.java
Modified: lucene/dev/trunk/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/CHANGES.txt?rev=1297423&r1=1297422&r2=1297423&view=diff
==============================================================================
--- lucene/dev/trunk/solr/CHANGES.txt (original)
+++ lucene/dev/trunk/solr/CHANGES.txt Tue Mar 6 11:08:14 2012
@@ -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
Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/admin/SystemInfoHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/admin/SystemInfoHandler.java?rev=1297423&r1=1297422&r2=1297423&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/admin/SystemInfoHandler.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/admin/SystemInfoHandler.java Tue Mar 6 11:08:14 2012
@@ -142,11 +142,12 @@ public class SystemInfoHandler extends R
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 R
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() );
+ }
}
}