forrest-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject svn commit: rev 20738 - in xml/forrest/trunk/src/forrestbot/webapp/src: java/org/apache/forrest/forrestbot/webapp/util webapp
Date Tue, 01 Jun 2004 15:38:09 GMT
Author: brondsem
Date: Tue Jun  1 08:38:08 2004
New Revision: 20738

Modified:
   xml/forrest/trunk/src/forrestbot/webapp/src/java/org/apache/forrest/forrestbot/webapp/util/Executor.java
   xml/forrest/trunk/src/forrestbot/webapp/src/webapp/viewlog_body.jsp
Log:
make sure all files are closed up

Modified: xml/forrest/trunk/src/forrestbot/webapp/src/java/org/apache/forrest/forrestbot/webapp/util/Executor.java
==============================================================================
--- xml/forrest/trunk/src/forrestbot/webapp/src/java/org/apache/forrest/forrestbot/webapp/util/Executor.java
(original)
+++ xml/forrest/trunk/src/forrestbot/webapp/src/java/org/apache/forrest/forrestbot/webapp/util/Executor.java
Tue Jun  1 08:38:08 2004
@@ -45,25 +45,36 @@
 
 	// we have to read from the buffer whether we're going to debug or not; on some systems
things will freeze up if the output isn't read
 	public void run() {
+        BufferedReader br = null;
 		try {
-			BufferedReader br = new BufferedReader(new InputStreamReader(is));
+			br = new BufferedReader(new InputStreamReader(is));
 			String line = null;
 			while ((line = br.readLine()) != null) {
 				if (debug)
 					log.log(type, line);
 			}
 		} catch (IOException ioe) {
-			ioe.printStackTrace();
+			log.error("error reading from process", ioe);
+		} finally {
+			if (br != null) {
+				try {
+					br.close();
+				} catch (IOException ioe2) {
+					log.error("couldn't cleanup after process IO exception", ioe2);
+				}
+			}
 		}
 	}
 }
 
 class ExecutorThread extends Thread {
 	private Process proc;
+	private Logger log;
 
 	public ExecutorThread(String id, Process p) {
 		super(id);
 		proc = p;
+		log = Logger.getLogger(Executor.class);
 	}
 
 	public void run() {
@@ -71,6 +82,13 @@
         errorGobbler.start();
 		StreamGobbler outputGobbler = new StreamGobbler(proc.getInputStream(), Priority.DEBUG);
 		outputGobbler.start();
+		try {
+			proc.getInputStream().close();
+			proc.getErrorStream().close();
+			proc.getOutputStream().close();
+		} catch (IOException ioe) {
+			log.error("couldn't close process's input/output streams", ioe);
+		}
 	}
 
 }

Modified: xml/forrest/trunk/src/forrestbot/webapp/src/webapp/viewlog_body.jsp
==============================================================================
--- xml/forrest/trunk/src/forrestbot/webapp/src/webapp/viewlog_body.jsp	(original)
+++ xml/forrest/trunk/src/forrestbot/webapp/src/webapp/viewlog_body.jsp	Tue Jun  1 08:38:08
2004
@@ -42,6 +42,7 @@
 	while ((line = in.readLine()) != null) {
 		out.println(line);
 	}
+	in.close();
 }
 %>
 </pre>

Mime
View raw message