diegoles / closure-library

Automatically exported from code.google.com/p/closure-library
0 stars 0 forks source link

goog.result.combine throws "Multiple attempts to set the state of this Result" when all results have already benn resolved. #495

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago

What steps will reproduce the problem?

Here is a simple testcase.

{{{
function testCombinePreresolvedResults() {
  var r1 = new goog.result.SimpleResult();
  var r2 = new goog.result.SimpleResult();
  r1.setValue(null);
  r2.setValue(null);
  goog.result.combine(r1, r2);
}
}}}

What is the expected output? What do you see instead?
The test should pass but it was failed with "Multiple attempts to set the state 
of this Result".

What version of the product are you using? On what operating system?
r2153

Please provide any additional information below.
Here is a patch to fix it.

{{{
Index: closure/goog/result/resultutil.js
===================================================================
--- closure/goog/result/resultutil.js   (revision 2153)
+++ closure/goog/result/resultutil.js   (working copy)
@@ -303,8 +303,10 @@
   };

   var checkResults = function() {
-    if (goog.array.every(results, isResolved)) {
-      combinedResult.setValue(results);
+    if (!isResolved(combinedResult)) {
+      if (goog.array.every(results, isResolved)) {
+        combinedResult.setValue(results);
+      }
     }
   };
}}}

Note: we cannot accept patches without the contributor license agreement
being signed. See http://code.google.com/p/closure-
library/wiki/Contributors for more info.

Original issue reported on code.google.com by sourcewa...@gmail.com on 11 Sep 2012 at 4:15