Related to issue Related to issue 29766: Retail Operations Buffer: store all transactions in operations table before processing
authorMartin Taal <martin.taal@openbravo.com>
Thu, 11 Jun 2015 12:37:01 +0200
changeset 26899 f6e2f6a4c29b
parent 26897 aab70f0c1a50
child 26900 aba1a9d25e4d
Related to issue Related to issue 29766: Retail Operations Buffer: store all transactions in operations table before processing
Added comments, removed not needed flush, apparently there is a case that the executorservice queue is null, handle this
src/org/openbravo/service/importprocess/ImportEntryManager.java
--- a/src/org/openbravo/service/importprocess/ImportEntryManager.java	Wed Jun 10 22:46:44 2015 +0000
+++ b/src/org/openbravo/service/importprocess/ImportEntryManager.java	Thu Jun 11 12:37:01 2015 +0200
@@ -188,7 +188,7 @@
   }
 
   public long getNumberOfQueuedTasks() {
-    return executorService.getQueue().size();
+    return executorService.getQueue() == null ? 0 : executorService.getQueue().size();
   }
 
   public long getNumberOfActiveTasks() {
@@ -238,9 +238,6 @@
    * Note will commit the session/connection using {@link OBDal#commitAndClose()}
    */
   public void createImportEntry(String id, String typeOfData, String json) {
-    // make sure that everything is flushed to the db before checking import entry
-    // content
-    OBDal.getInstance().flush();
     OBContext.setAdminMode(true);
     try {
       // check if it is not there already or already archived
@@ -398,7 +395,9 @@
     final OBContext prevOBContext = OBContext.getOBContext();
     OBContext.setOBContext("0", "0", "0", "0");
     try {
-      // no need to do client/org checks on these actions, as in error, do the least possible
+      // do not do org/client check as the error can be related to org/client access
+      // so prevent this check to be done to even be able to save org/client access
+      // checks
       OBContext.setAdminMode(false);
       ImportEntry importEntry = OBDal.getInstance().get(ImportEntry.class, importEntryId);
       if (importEntry != null && !"Processed".equals(importEntry.getImportStatus())) {
@@ -475,7 +474,8 @@
           try {
 
             // too busy, don't process, but wait
-            if (manager.executorService.getQueue().size() > (manager.maxTaskQueueSize - 1)) {
+            if (manager.executorService.getQueue() != null
+                && manager.executorService.getQueue().size() > (manager.maxTaskQueueSize - 1)) {
               doWait();
               // woken, re-start from beginning of loop
               continue;