Related to issue 31368: Add log in importprocess to get more information if it fails
authorMartin Taal <martin.taal@openbravo.com>
Fri, 06 Nov 2015 00:47:51 +0100
changeset 27838 b4ce1b7f9243
parent 27837 e43fcd8f3d3a
child 27839 7ba06ba5da79
Related to issue 31368: Add log in importprocess to get more information if it fails
Don't wait the min 2 seconds in test mode
src/org/openbravo/service/importprocess/ImportEntryManager.java
--- a/src/org/openbravo/service/importprocess/ImportEntryManager.java	Thu Nov 05 19:00:37 2015 +0100
+++ b/src/org/openbravo/service/importprocess/ImportEntryManager.java	Fri Nov 06 00:47:51 2015 +0100
@@ -45,6 +45,7 @@
 import org.hibernate.ScrollableResults;
 import org.openbravo.base.exception.OBException;
 import org.openbravo.base.provider.OBProvider;
+import org.openbravo.base.session.OBPropertiesProvider;
 import org.openbravo.dal.core.OBContext;
 import org.openbravo.dal.core.SessionHandler;
 import org.openbravo.dal.service.OBDal;
@@ -469,6 +470,8 @@
 
       Thread.currentThread().setName("Import Entry Manager Main");
 
+      boolean isTest = OBPropertiesProvider.getInstance().getBooleanProperty("test.environment");
+
       // don't start right away at startup, give the system time to
       // really start
       log.debug("Started, first sleep " + manager.initialWaitTime);
@@ -570,7 +573,13 @@
               try {
                 // wait one second per 30 records, somewhat arbitrary
                 // but high enough for most cases
-                Thread.sleep(Math.max(2000, 1000 * (entryCount / 30)));
+                if (isTest) {
+                  // in case of test don't wait minimal 2 seconds
+                  Thread.sleep(1000 * (entryCount / 30));
+                } else {
+                  // wait minimal 2 seconds or based on entry count
+                  Thread.sleep(Math.max(2000, 1000 * (entryCount / 30)));
+                }
               } catch (Exception ignored) {
               }
             } else {