public
Description: My generally useful java library I take wherever I go.
Homepage: http://bleu.west.spy.net/~dustin/projects/spyjar/
Clone URL: git://github.com/dustin/spyjar.git
Got rid of BrokenPromiseException
dustin (author)
Mon Dec 10 21:19:23 -0800 2007
commit  5e9cd9602ad54981f5d7333e3b83ca4455fb7dfd
tree    aaa2a536150cca35942132216d29d5a9ad8cd41e
parent  936b3005d48d971b5b4920b4535545daeb3fef17
...
9
10
11
12
 
13
14
15
...
23
24
25
26
27
 
 
28
29
 
30
31
32
33
34
35
 
36
37
38
...
77
78
79
80
 
81
82
...
9
10
11
 
12
13
14
15
...
23
24
25
 
 
26
27
28
 
29
30
31
32
33
34
 
35
36
37
38
...
77
78
79
 
80
81
82
0
@@ -9,7 +9,7 @@ public abstract class Promise<T> extends Object {
0
 
0
   private T rv=null;
0
   private volatile boolean hasRun=false;
0
- private BrokenPromiseException bpe=null;
0
+ private RuntimeException bpe=null;
0
 
0
   /**
0
    * Get an instance of Promise.
0
@@ -23,16 +23,16 @@ public abstract class Promise<T> extends Object {
0
    *
0
    * @return the Object we were promised.
0
    *
0
- * @exception BrokenPromiseException if there's a problem getting what
0
- * we were promised.
0
+ * @exception RuntimeException if there's a problem getting what
0
+ * we were promised.
0
    */
0
- public final T get() throws BrokenPromiseException {
0
+ public final T get() {
0
     if(hasRun == false) {
0
       synchronized(this) {
0
         if(hasRun == false) {
0
           try {
0
             rv=execute();
0
- } catch(BrokenPromiseException e) {
0
+ } catch(RuntimeException e) {
0
             this.bpe=e;
0
             throw e;
0
           } finally {
0
@@ -77,6 +77,6 @@ public abstract class Promise<T> extends Object {
0
   /**
0
    * Do the actual work required to get the Object we're promised.
0
    */
0
- protected abstract T execute() throws BrokenPromiseException;
0
+ protected abstract T execute();
0
 
0
 }
...
4
5
6
7
8
9
10
 
 
11
12
13
...
48
49
50
51
 
52
53
54
...
58
59
60
61
 
62
63
64
...
70
71
72
73
 
74
75
76
77
78
 
79
80
81
...
94
95
96
97
 
98
99
100
...
106
107
108
109
110
 
 
111
112
113
...
117
118
119
120
 
121
122
123
...
4
5
6
 
 
7
8
9
10
11
12
13
...
48
49
50
 
51
52
53
54
...
58
59
60
 
61
62
63
64
...
70
71
72
 
73
74
75
76
77
 
78
79
80
81
...
94
95
96
 
97
98
99
100
...
106
107
108
 
 
109
110
111
112
113
...
117
118
119
 
120
121
122
123
0
@@ -4,10 +4,10 @@ package net.spy.util;
0
 
0
 import java.util.concurrent.Callable;
0
 
0
-import net.spy.test.SyncThread;
0
-
0
 import junit.framework.TestCase;
0
 
0
+import net.spy.test.SyncThread;
0
+
0
 /**
0
  * Test the promise implementation.
0
  */
0
@@ -48,7 +48,7 @@ public class PromiseTest extends TestCase {
0
     try {
0
       Object o=p.get();
0
       fail("Broken promise gave me a value: " + o);
0
- } catch(BrokenPromiseException e) {
0
+ } catch(RuntimeException e) {
0
       // pass
0
     }
0
     assertTrue("Got: " + String.valueOf(p),
0
@@ -58,7 +58,7 @@ public class PromiseTest extends TestCase {
0
     try {
0
       Object o=p.get();
0
       fail("Broken promise gave me a value the second time: " + o);
0
- } catch(BrokenPromiseException e) {
0
+ } catch(RuntimeException e) {
0
       // pass
0
     }
0
   }
0
@@ -70,12 +70,12 @@ public class PromiseTest extends TestCase {
0
   }
0
 
0
   public void testBrokenPromiseException() {
0
- BrokenPromiseException e=new BrokenPromiseException("test");
0
+ RuntimeException e=new RuntimeException("test");
0
     assertEquals("test", e.getMessage());
0
     assertNull(e.getCause());
0
 
0
     Exception e2=new Exception();
0
- e=new BrokenPromiseException("test", e2);
0
+ e=new RuntimeException("test", e2);
0
     assertEquals("test", e.getMessage());
0
     assertSame(e2, e.getCause());
0
   }
0
@@ -94,7 +94,7 @@ public class PromiseTest extends TestCase {
0
     }
0
 
0
     @Override
0
- protected Integer execute() throws BrokenPromiseException {
0
+ protected Integer execute() {
0
       return new Integer(myInt++);
0
     }
0
 
0
@@ -106,8 +106,8 @@ public class PromiseTest extends TestCase {
0
     }
0
 
0
     @Override
0
- protected Object execute() throws BrokenPromiseException {
0
- throw new BrokenPromiseException("Fail");
0
+ protected Object execute() {
0
+ throw new RuntimeException("Fail");
0
     }
0
   }
0
 
0
@@ -117,7 +117,7 @@ public class PromiseTest extends TestCase {
0
     }
0
 
0
     @Override
0
- protected Object execute() throws BrokenPromiseException {
0
+ protected Object execute() {
0
       return(null);
0
     }
0
   }

Comments

    No one has commented yet.