[open-ils-commits] [GIT] Evergreen ILS branch master updated. 474afc4472f737f2f17d290f854f733209487d96

Evergreen Git git at git.evergreen-ils.org
Wed Sep 20 21:26:39 EDT 2017


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".

The branch, master has been updated
       via  474afc4472f737f2f17d290f854f733209487d96 (commit)
      from  41dc920959cf4f793e993839b3108b5ae257773c (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 474afc4472f737f2f17d290f854f733209487d96
Author: Galen Charlton <gmc at equinoxinitiative.org>
Date:   Wed Sep 20 21:07:37 2017 -0400

    LP#1718301: catch it when multiple connection attempts fail
    
    Lovefield only allows a single connection at a time, and throws
    an exception if a second attempt is made.  In the context of a
    page app, wrapping the connection attempt in a promise takes
    care of it, but for the test suite, the egLoveField service
    gets completely reinitialized... but Lovefield itself still
    thinks it's in the middle of connecting.
    
    This patch catches the exception and allows the test suite to
    pass, without otherwise affecting use in a real browser.
    
    Signed-off-by: Galen Charlton <gmc at equinoxinitiative.org>
    Signed-off-by: Ben Shum <ben at evergreener.net>

diff --git a/Open-ILS/web/js/ui/default/staff/services/lovefield.js b/Open-ILS/web/js/ui/default/staff/services/lovefield.js
index 0621911..dfebc4b 100644
--- a/Open-ILS/web/js/ui/default/staff/services/lovefield.js
+++ b/Open-ILS/web/js/ui/default/staff/services/lovefield.js
@@ -41,7 +41,7 @@ angular.module('egCoreMod')
 
 .factory('egLovefield', ['$q','$rootScope','egCore','$timeout', 
                  function($q , $rootScope , egCore , $timeout) { 
-    
+
     var service = {};
 
     function connectOrGo() {
@@ -63,20 +63,27 @@ angular.module('egCoreMod')
         var deferred = $q.defer();
 
         console.debug('attempting offline DB connection');
-        osb.connect().then(
-            function(db) {
-                console.debug('successfully connected to offline DB');
-                service.connectPromise = null;
-                lf.offlineDB = db;
-                deferred.resolve();
-            },
-            function(err) {
-                // assumes that a single connection failure means
-                // a connection will never succeed.
-                service.cannotConnect = true;
-                console.error('Cannot connect to offline DB: ' + err);
-            }
-        );
+        try {
+            osb.connect().then(
+                function(db) {
+                    console.debug('successfully connected to offline DB');
+                    service.connectPromise = null;
+                    lf.offlineDB = db;
+                    deferred.resolve();
+                },
+                function(err) {
+                    // assumes that a single connection failure means
+                    // a connection will never succeed.
+                    service.cannotConnect = true;
+                    console.error('Cannot connect to offline DB: ' + err);
+                }
+            );
+        } catch (e) {
+            // .connect() will throw an error if it detects that a connection
+            // attempt is already in progress; this can happen with PhantomJS
+            console.error('Cannot connect to offline DB: ' + e);
+            service.cannotConnect = true;
+        }
 
         service.connectPromise = deferred.promise;
         return service.connectPromise;

-----------------------------------------------------------------------

Summary of changes:
 .../web/js/ui/default/staff/services/lovefield.js  |   37 ++++++++++++--------
 1 files changed, 22 insertions(+), 15 deletions(-)


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list