File tree Expand file tree Collapse file tree 5 files changed +67
-0
lines changed 
guava-tests/test/com/google/common/util/concurrent 
guava/src/com/google/common/util/concurrent 
guava-gwt/test/com/google/common/util/concurrent 
guava-tests/test/com/google/common/util/concurrent 
guava/src/com/google/common/util/concurrent Expand file tree Collapse file tree 5 files changed +67
-0
lines changed Original file line number Diff line number Diff line change 3131import  static  com .google .common .util .concurrent .Futures .immediateCancelledFuture ;
3232import  static  com .google .common .util .concurrent .Futures .immediateFailedFuture ;
3333import  static  com .google .common .util .concurrent .Futures .immediateFuture ;
34+ import  static  com .google .common .util .concurrent .Futures .immediateVoidFuture ;
3435import  static  com .google .common .util .concurrent .Futures .inCompletionOrder ;
3536import  static  com .google .common .util .concurrent .Futures .lazyTransform ;
3637import  static  com .google .common .util .concurrent .Futures .nonCancellationPropagating ;
@@ -138,6 +139,14 @@ public void testImmediateFuture() throws Exception {
138139    assertThat (future .toString ()).contains ("[status=SUCCESS, result=["  + DATA1  + "]]" );
139140  }
140141
142+   public  void  testImmediateVoidFuture () throws  Exception  {
143+     ListenableFuture <Void > voidFuture  = immediateVoidFuture ();
144+ 
145+     assertThat (getDone (voidFuture )).isNull ();
146+     assertThat (getDoneFromTimeoutOverload (voidFuture )).isNull ();
147+     assertThat (voidFuture .toString ()).contains ("[status=SUCCESS, result=[null]]" );
148+   }
149+ 
141150  public  void  testImmediateFailedFuture () throws  Exception  {
142151    Exception  exception  = new  Exception ();
143152    ListenableFuture <String > future  = immediateFailedFuture (exception );
Original file line number Diff line number Diff line change @@ -135,6 +135,17 @@ public static <V> ListenableFuture<V> immediateFuture(@NullableDecl V value) {
135135    return  new  ImmediateFuture <>(value );
136136  }
137137
138+   /** 
139+    * Returns a successful {@code ListenableFuture<Void>}. This method is equivalent to {@code 
140+    * immediateFuture(null)} except that it is restricted to produce futures of type {@code Void}. 
141+    * 
142+    * @since NEXT 
143+    */ 
144+   @ SuppressWarnings ("unchecked" )
145+   public  static  ListenableFuture <Void > immediateVoidFuture () {
146+     return  (ListenableFuture <Void >) ImmediateFuture .NULL ;
147+   }
148+ 
138149  /** 
139150   * Returns a {@code ListenableFuture} which has an exception set immediately upon construction. 
140151   * 
Original file line number Diff line number Diff line change @@ -1746,6 +1746,33 @@ public void testImmediateFuture() throws Exception {
17461746  }
17471747}
17481748
1749+ public  void  testImmediateVoidFuture () throws  Exception  {
1750+   com .google .common .util .concurrent .FuturesTest  testCase  = new  com .google .common .util .concurrent .FuturesTest ();
1751+   testCase .setUp ();
1752+   Throwable  failure  = null ;
1753+   try  {
1754+     testCase .testImmediateVoidFuture ();
1755+   } catch  (Throwable  t ) {
1756+     failure  = t ;
1757+   }
1758+   try  {
1759+     testCase .tearDown ();
1760+   } catch  (Throwable  t ) {
1761+     if  (failure  == null ) {
1762+       failure  = t ;
1763+     }
1764+   }
1765+   if  (failure  instanceof  Exception ) {
1766+     throw  (Exception ) failure ;
1767+   }
1768+   if  (failure  instanceof  Error ) {
1769+     throw  (Error ) failure ;
1770+   }
1771+   if  (failure  != null ) {
1772+     throw  new  RuntimeException (failure );
1773+   }
1774+ }
1775+ 
17491776public  void  testNonCancellationPropagating_delegateCancelled () throws  Exception  {
17501777  com .google .common .util .concurrent .FuturesTest  testCase  = new  com .google .common .util .concurrent .FuturesTest ();
17511778  testCase .setUp ();
Original file line number Diff line number Diff line change 3131import  static  com .google .common .util .concurrent .Futures .immediateCancelledFuture ;
3232import  static  com .google .common .util .concurrent .Futures .immediateFailedFuture ;
3333import  static  com .google .common .util .concurrent .Futures .immediateFuture ;
34+ import  static  com .google .common .util .concurrent .Futures .immediateVoidFuture ;
3435import  static  com .google .common .util .concurrent .Futures .inCompletionOrder ;
3536import  static  com .google .common .util .concurrent .Futures .lazyTransform ;
3637import  static  com .google .common .util .concurrent .Futures .nonCancellationPropagating ;
@@ -138,6 +139,14 @@ public void testImmediateFuture() throws Exception {
138139    assertThat (future .toString ()).contains ("[status=SUCCESS, result=["  + DATA1  + "]]" );
139140  }
140141
142+   public  void  testImmediateVoidFuture () throws  Exception  {
143+     ListenableFuture <Void > voidFuture  = immediateVoidFuture ();
144+ 
145+     assertThat (getDone (voidFuture )).isNull ();
146+     assertThat (getDoneFromTimeoutOverload (voidFuture )).isNull ();
147+     assertThat (voidFuture .toString ()).contains ("[status=SUCCESS, result=[null]]" );
148+   }
149+ 
141150  public  void  testImmediateFailedFuture () throws  Exception  {
142151    Exception  exception  = new  Exception ();
143152    ListenableFuture <String > future  = immediateFailedFuture (exception );
Original file line number Diff line number Diff line change @@ -137,6 +137,17 @@ public static <V> ListenableFuture<V> immediateFuture(@Nullable V value) {
137137    return  new  ImmediateFuture <>(value );
138138  }
139139
140+   /** 
141+    * Returns a successful {@code ListenableFuture<Void>}. This method is equivalent to {@code 
142+    * immediateFuture(null)} except that it is restricted to produce futures of type {@code Void}. 
143+    * 
144+    * @since NEXT 
145+    */ 
146+   @ SuppressWarnings ("unchecked" )
147+   public  static  ListenableFuture <Void > immediateVoidFuture () {
148+     return  (ListenableFuture <Void >) ImmediateFuture .NULL ;
149+   }
150+ 
140151  /** 
141152   * Returns a {@code ListenableFuture} which has an exception set immediately upon construction. 
142153   * 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments