svn commit: r1797788 - in /ofbiz/ofbiz-plugins/trunk/scrum/groovyScripts: AddProductBacklogItem.groovy ListScrumResource.groovy ListTimeSheets.groovy

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1797788 - in /ofbiz/ofbiz-plugins/trunk/scrum/groovyScripts: AddProductBacklogItem.groovy ListScrumResource.groovy ListTimeSheets.groovy

jleroux@apache.org
Author: jleroux
Date: Tue Jun  6 13:59:29 2017
New Revision: 1797788

URL: http://svn.apache.org/viewvc?rev=1797788&view=rev
Log:
Improved: performFindResults.listIt closed but not in case of exception in 3
Scrum Groovy files
(OFBIZ-9389)

This is an improvement only because no cases were reported. But obviously in
case of unlucky exception after the call to the performFind service, and before
it's closed, the EntityListIterator remains in memory.

The solution is to use a try-catch-finally block because Groovy has not
try-with-ressources.

Modified:
    ofbiz/ofbiz-plugins/trunk/scrum/groovyScripts/AddProductBacklogItem.groovy
    ofbiz/ofbiz-plugins/trunk/scrum/groovyScripts/ListScrumResource.groovy
    ofbiz/ofbiz-plugins/trunk/scrum/groovyScripts/ListTimeSheets.groovy

Modified: ofbiz/ofbiz-plugins/trunk/scrum/groovyScripts/AddProductBacklogItem.groovy
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-plugins/trunk/scrum/groovyScripts/AddProductBacklogItem.groovy?rev=1797788&r1=1797787&r2=1797788&view=diff
==============================================================================
--- ofbiz/ofbiz-plugins/trunk/scrum/groovyScripts/AddProductBacklogItem.groovy (original)
+++ ofbiz/ofbiz-plugins/trunk/scrum/groovyScripts/AddProductBacklogItem.groovy Tue Jun  6 13:59:29 2017
@@ -38,8 +38,19 @@ if(parameters.statusId == null){
 inputFields.putAll(parameters)
 inputFields.custRequestTypeId = "RF_PROD_BACKLOG"
 def performFindResults = runService('performFind', ["entityName": "CustRequestAndCustRequestItem", "inputFields": inputFields, "orderBy": "custSequenceNum"])
-def custRequestAndItems = performFindResults.listIt.getCompleteList()
-performFindResults.listIt.close()
+try {
+    def custRequestAndItems = performFindResults.listIt.getCompleteList()
+} catch (GenericEntityException e) {
+    Debug.logError(e, "Failure in " + module)
+} finally {
+    if (performFindResults.listIt != null) {
+        try {
+            performFindResults.listIt.close()
+            } catch (GenericEntityException e) {
+                Debug.logError(e, module);
+            }
+    }
+}
 
 // prepare cust request item list [cust request and item Map]
 def countSequence = 1

Modified: ofbiz/ofbiz-plugins/trunk/scrum/groovyScripts/ListScrumResource.groovy
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-plugins/trunk/scrum/groovyScripts/ListScrumResource.groovy?rev=1797788&r1=1797787&r2=1797788&view=diff
==============================================================================
--- ofbiz/ofbiz-plugins/trunk/scrum/groovyScripts/ListScrumResource.groovy (original)
+++ ofbiz/ofbiz-plugins/trunk/scrum/groovyScripts/ListScrumResource.groovy Tue Jun  6 13:59:29 2017
@@ -37,11 +37,23 @@ performFindInMap.noConditionFind = "Y"
 performFindInMap.inputFields = inputFields
 performFindInMap.orderBy = parameters.sortField
 if (parameters.sortField) {
- performFindInMap.orderBy = "lastName"
+    performFindInMap.orderBy = "lastName"
 }
 performFindResults = runService('performFind', performFindInMap)
-resultList = performFindResults.listIt.getCompleteList()
-performFindResults.listIt.close()
+try {
+    resultList = performFindResults.listIt.getCompleteList()
+} catch (GenericEntityException e) {
+    Debug.logError(e, "Failure in " + module)
+} finally {
+    if (performFindResults.listIt != null) {
+        try {
+            performFindResults.listIt.close()
+            } catch (GenericEntityException e) {
+                Debug.logError(e, module);
+            }
+    }
+}
+
 
 resultList.each() { result ->
     if (!"N".equals(result.enabled)) {

Modified: ofbiz/ofbiz-plugins/trunk/scrum/groovyScripts/ListTimeSheets.groovy
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-plugins/trunk/scrum/groovyScripts/ListTimeSheets.groovy?rev=1797788&r1=1797787&r2=1797788&view=diff
==============================================================================
--- ofbiz/ofbiz-plugins/trunk/scrum/groovyScripts/ListTimeSheets.groovy (original)
+++ ofbiz/ofbiz-plugins/trunk/scrum/groovyScripts/ListTimeSheets.groovy Tue Jun  6 13:59:29 2017
@@ -24,6 +24,7 @@ import org.apache.ofbiz.base.util.Debug
 import org.apache.ofbiz.base.util.UtilDateTime
 
 // get all timesheets of all user, including the planned hours
+module ="ListTimeSheets.groovy"
 timesheets = []
 inputFields = [:]
 
@@ -33,8 +34,19 @@ if (!parameters.noConditionFind) {
 inputFields.putAll(parameters)
 performFindResults = runService('performFind', ["entityName": "Timesheet", "inputFields": inputFields, "orderBy": "fromDate DESC"])
 if (performFindResults.listSize > 0) {
-    timesheetsDb = performFindResults.listIt.getCompleteList()
-    performFindResults.listIt.close()
+    try {
+        timesheetsDb = performFindResults.listIt.getCompleteList()
+    } catch (GenericEntityException e) {
+        Debug.logError(e, "Failure in " + module)
+    } finally {
+        if (performFindResults.listIt != null) {
+            try {
+                performFindResults.listIt.close()
+                } catch (GenericEntityException e) {
+                    Debug.logError(e, module);
+                }
+        }
+    }
     
     timesheetsDb.each { timesheetDb ->
         //get hours from EmplLeave