Author: doogie
Date: Sat Sep 12 23:23:49 2009 New Revision: 814251 URL: http://svn.apache.org/viewvc?rev=814251&view=rev Log: Protect closing of the EntityListIterator inside a finally block. Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/Iterate.java Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/Iterate.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/Iterate.java?rev=814251&r1=814250&r2=814251&view=diff ============================================================================== --- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/Iterate.java (original) +++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/Iterate.java Sat Sep 12 23:23:49 2009 @@ -78,29 +78,31 @@ EntityListIterator eli = (EntityListIterator) objList; GenericValue theEntry; - while ((theEntry = eli.next()) != null) { - entryAcsr.put(methodContext, theEntry); + try { + while ((theEntry = eli.next()) != null) { + entryAcsr.put(methodContext, theEntry); - if (!SimpleMethod.runSubOps(subOps, methodContext)) { - // only return here if it returns false, otherwise just carry on - return false; + if (!SimpleMethod.runSubOps(subOps, methodContext)) { + // only return here if it returns false, otherwise just carry on + return false; + } } - } - - // close the iterator - try { - eli.close(); - } catch (GenericEntityException e) { - Debug.logError(e, module); - String errMsg = "ERROR: Error closing entityListIterator in " + simpleMethod.getShortDescription() + " [" + e.getMessage() + "]: " + rawString(); - if (methodContext.getMethodType() == MethodContext.EVENT) { - methodContext.putEnv(simpleMethod.getEventErrorMessageName(), errMsg); - methodContext.putEnv(simpleMethod.getEventResponseCodeName(), simpleMethod.getDefaultErrorCode()); - } else if (methodContext.getMethodType() == MethodContext.SERVICE) { - methodContext.putEnv(simpleMethod.getServiceErrorMessageName(), errMsg); - methodContext.putEnv(simpleMethod.getServiceResponseMessageName(), simpleMethod.getDefaultErrorCode()); + } finally { + // close the iterator + try { + eli.close(); + } catch (GenericEntityException e) { + Debug.logError(e, module); + String errMsg = "ERROR: Error closing entityListIterator in " + simpleMethod.getShortDescription() + " [" + e.getMessage() + "]: " + rawString(); + if (methodContext.getMethodType() == MethodContext.EVENT) { + methodContext.putEnv(simpleMethod.getEventErrorMessageName(), errMsg); + methodContext.putEnv(simpleMethod.getEventResponseCodeName(), simpleMethod.getDefaultErrorCode()); + } else if (methodContext.getMethodType() == MethodContext.SERVICE) { + methodContext.putEnv(simpleMethod.getServiceErrorMessageName(), errMsg); + methodContext.putEnv(simpleMethod.getServiceResponseMessageName(), simpleMethod.getDefaultErrorCode()); + } + return false; } - return false; } } else { Collection<Object> theList = UtilGenerics.checkList(objList); |
Free forum by Nabble | Edit this page |