You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by sa...@apache.org on 2011/09/16 08:04:22 UTC
svn commit: r1171393 - in /ofbiz/trunk/framework:
minilang/src/org/ofbiz/minilang/method/callops/CallBsh.java
start/src/org/ofbiz/base/start/Start.java
webapp/src/org/ofbiz/webapp/event/XmlRpcEventHandler.java
Author: sascharodekamp
Date: Fri Sep 16 06:04:21 2011
New Revision: 1171393
URL: http://svn.apache.org/viewvc?rev=1171393&view=rev
Log:
FIX: IO stream objects are not closed (https://issues.apache.org/jira/browse/OFBIZ-4420) A patch from Dimitri Unruh: Some methods are creating an IO stream object without closing it, so it could result on a descriptor leak.
Modified:
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/callops/CallBsh.java
ofbiz/trunk/framework/start/src/org/ofbiz/base/start/Start.java
ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/XmlRpcEventHandler.java
Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/callops/CallBsh.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/callops/CallBsh.java?rev=1171393&r1=1171392&r2=1171393&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/callops/CallBsh.java (original)
+++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/callops/CallBsh.java Fri Sep 16 06:04:21 2011
@@ -88,8 +88,9 @@ public class CallBsh extends MethodOpera
if (is == null) {
messages.add("Could not find bsh resource: " + resource);
} else {
+ BufferedReader reader = null;
try {
- BufferedReader reader = new BufferedReader(new InputStreamReader(is));
+ reader = new BufferedReader(new InputStreamReader(is));
StringBuilder outSb = new StringBuilder();
String tempStr = null;
@@ -107,6 +108,14 @@ public class CallBsh extends MethodOpera
}
} catch (IOException e) {
messages.add("IO error loading bsh resource: " + e.getMessage());
+ } finally {
+ if (reader != null) {
+ try {
+ reader.close();
+ } catch (IOException e) {
+ messages.add("IO error closing BufferedReader: " + e.getMessage());
+ }
+ }
}
}
}
Modified: ofbiz/trunk/framework/start/src/org/ofbiz/base/start/Start.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/start/src/org/ofbiz/base/start/Start.java?rev=1171393&r1=1171392&r2=1171393&view=diff
==============================================================================
--- ofbiz/trunk/framework/start/src/org/ofbiz/base/start/Start.java (original)
+++ ofbiz/trunk/framework/start/src/org/ofbiz/base/start/Start.java Fri Sep 16 06:04:21 2011
@@ -152,10 +152,20 @@ public class Start {
public void init(String[] args, boolean fullInit) throws IOException {
String globalSystemPropsFileName = System.getProperty("ofbiz.system.props");
if (globalSystemPropsFileName != null) {
+ FileInputStream stream = null;
try {
- System.getProperties().load(new FileInputStream(globalSystemPropsFileName));
+ stream = new FileInputStream(globalSystemPropsFileName);
+ System.getProperties().load(stream);
} catch (IOException e) {
throw (IOException) new IOException("Couldn't load global system props").initCause(e);
+ } finally {
+ if (stream != null){
+ try {
+ stream.close();
+ } catch (IOException e) {
+ throw new IOException(e);
+ }
+ }
}
}
this.config = Config.getInstance(args);
Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/XmlRpcEventHandler.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/XmlRpcEventHandler.java?rev=1171393&r1=1171392&r2=1171393&view=diff
==============================================================================
--- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/XmlRpcEventHandler.java (original)
+++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/XmlRpcEventHandler.java Fri Sep 16 06:04:21 2011
@@ -95,16 +95,25 @@ public class XmlRpcEventHandler extends
public String invoke(Event event, RequestMap requestMap, HttpServletRequest request, HttpServletResponse response) throws EventHandlerException {
String report = request.getParameter("echo");
if (report != null) {
+ BufferedReader reader = null;
StringBuilder buf = new StringBuilder();
try {
// read the inputstream buffer
String line;
- BufferedReader reader = new BufferedReader(new InputStreamReader(request.getInputStream()));
+ reader = new BufferedReader(new InputStreamReader(request.getInputStream()));
while ((line = reader.readLine()) != null) {
buf.append(line).append("\n");
}
} catch (Exception e) {
throw new EventHandlerException(e.getMessage(), e);
+ } finally {
+ if (reader != null) {
+ try {
+ reader.close();
+ } catch (IOException e) {
+ throw new EventHandlerException(e.getMessage(), e);
+ }
+ }
}
Debug.logInfo("Echo: " + buf.toString(), module);