40
40
import com .google .api .generator .engine .ast .ScopeNode ;
41
41
import com .google .api .generator .engine .ast .Statement ;
42
42
import com .google .api .generator .engine .ast .ThisObjectValue ;
43
- import com .google .api .generator .engine .ast .ThrowExpr ;
44
- import com .google .api .generator .engine .ast .TryCatchStatement ;
45
43
import com .google .api .generator .engine .ast .TypeNode ;
46
44
import com .google .api .generator .engine .ast .ValueExpr ;
47
45
import com .google .api .generator .engine .ast .Variable ;
@@ -793,23 +791,6 @@ private List<MethodDefinition> createStubOverrideMethods(
793
791
.build ())
794
792
.build ();
795
793
796
- // Generate the close() method:
797
- // @Override
798
- // public final void close() {
799
- // try {
800
- // backgroundResources.close();
801
- // } catch (Exception e) {
802
- // throw new IllegalStateException("Failed to close resource", e);
803
- // }
804
- // }
805
- VariableExpr catchExceptionVarExpr =
806
- VariableExpr .builder ()
807
- .setVariable (
808
- Variable .builder ()
809
- .setType (TypeNode .withExceptionClazz (Exception .class ))
810
- .setName ("e" )
811
- .build ())
812
- .build ();
813
794
List <MethodDefinition > javaMethods = new ArrayList <>();
814
795
javaMethods .add (
815
796
methodMakerStarterFn
@@ -818,26 +799,8 @@ private List<MethodDefinition> createStubOverrideMethods(
818
799
.setReturnType (TypeNode .VOID )
819
800
.setBody (
820
801
Arrays .asList (
821
- TryCatchStatement .builder ()
822
- .setTryBody (
823
- Arrays .asList (
824
- ExprStatement .withExpr (
825
- MethodInvocationExpr .builder ()
826
- .setExprReferenceExpr (backgroundResourcesVarExpr )
827
- .setMethodName ("close" )
828
- .build ())))
829
- .addCatch (
830
- catchExceptionVarExpr .toBuilder ().setIsDecl (true ).build (),
831
- Arrays .asList (
832
- ExprStatement .withExpr (
833
- ThrowExpr .builder ()
834
- .setType (
835
- TypeNode .withExceptionClazz (
836
- IllegalStateException .class ))
837
- .setMessageExpr (String .format ("Failed to close resource" ))
838
- .setCauseExpr (catchExceptionVarExpr )
839
- .build ())))
840
- .build ()))
802
+ ExprStatement .withExpr (
803
+ MethodInvocationExpr .builder ().setMethodName ("shutdown" ).build ())))
841
804
.build ());
842
805
javaMethods .add (voidMethodMakerFn .apply ("shutdown" ));
843
806
javaMethods .add (booleanMethodMakerFn .apply ("isShutdown" ));
0 commit comments