"Applied fix from trunk framework for revision: 1842372  " 
------------------------------------------------------------------------
r1842372 | jleroux | 2018-09-30 15:49:30 +0200 (dim. 30 sept. 2018) | 11 lignes

Fixed: Service Log screen is broken
(OFBIZ-10342)

Steps to regenerate

    Navigate to Logging menu under webtools
    https://demo-trunk.ofbiz.apache.org/webtools/control/LogView

    Select Service Log menu, see NPE error

Thanks: Swapnil M Mane for report and Swapnil and Rishi Solanki for reviews
------------------------------------------------------------------------


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/branches/release16.11@1842374 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/service/src/main/java/org/apache/ofbiz/service/ServiceDispatcher.java b/framework/service/src/main/java/org/apache/ofbiz/service/ServiceDispatcher.java
index 6d37f7d..274b388 100644
--- a/framework/service/src/main/java/org/apache/ofbiz/service/ServiceDispatcher.java
+++ b/framework/service/src/main/java/org/apache/ofbiz/service/ServiceDispatcher.java
@@ -300,6 +300,7 @@
                     if (modelService.requireNewTransaction) {
                         parentTransaction = TransactionUtil.suspend();
                         if (TransactionUtil.isTransactionInPlace()) {
+                            rs.setEndStamp();
                             throw new GenericTransactionException("In service " + modelService.name + " transaction is still in place after suspend, status is " + TransactionUtil.getStatusString());
                         }
                         // now start a new transaction
@@ -353,6 +354,7 @@
                     GenericValue userLogin = (GenericValue) context.get("userLogin");
 
                     if (modelService.auth && userLogin == null) {
+                        rs.setEndStamp();
                         throw new ServiceAuthException("User authorization is required for this service: " + modelService.name + modelService.debugInfo());
                     }
 
@@ -376,6 +378,7 @@
                             modelService.validate(context, ModelService.IN_PARAM, locale);
                         } catch (ServiceValidationException e) {
                             Debug.logError(e, "Incoming context (in runSync : " + modelService.name + ") does not match expected requirements", module);
+                            rs.setEndStamp();
                             throw e;
                         }
                     }
@@ -484,6 +487,7 @@
                     try {
                         modelService.validate(result, ModelService.OUT_PARAM, locale);
                     } catch (ServiceValidationException e) {
+                        rs.setEndStamp();
                         throw new GenericServiceException("Outgoing result (in runSync : " + modelService.name + ") does not match expected requirements", e);
                     }
                 }
@@ -546,6 +550,7 @@
                         if (e.getMessage() != null) {
                             errMsg = errMsg + ": " + e.getMessage();
                         }
+                        rs.setEndStamp();
                         throw new GenericServiceException(errMsg);
                     }
                 }
@@ -558,6 +563,7 @@
             }
         } catch (GenericTransactionException te) {
             Debug.logError(te, "Problems with the transaction", module);
+            rs.setEndStamp();
             throw new GenericServiceException("Problems with the transaction.", te.getNested());
         } finally {
             if (lock != null) {
@@ -575,6 +581,7 @@
                     TransactionUtil.resume(parentTransaction);
                 } catch (GenericTransactionException ite) {
                     Debug.logWarning(ite, "Transaction error, not resumed", module);
+                    rs.setEndStamp();
                     throw new GenericServiceException("Resume transaction exception, see logs");
                 }
             }