@@ -822,21 +822,24 @@ public void rollback() throws SQLException {
822822 "Cannot rollback without an active transaction. Please set setAutoCommit to false to"
823823 + " start a transaction." );
824824 }
825- try {
826- QueryJobConfiguration transactionRollbackJobConfig =
827- QueryJobConfiguration .newBuilder ("ROLLBACK TRANSACTION;" )
828- .setConnectionProperties (this .queryProperties )
829- .build ();
830- Job rollbackJob = this .bigQuery .create (JobInfo .of (transactionRollbackJobConfig ));
831- rollbackJob .waitFor ();
832- this .transactionStarted = false ;
833- if (!getAutoCommit ()) {
834- beginTransaction ();
835- }
836- } catch (InterruptedException | BigQueryException ex ) {
837- LOG .severe (ex , "Failed to rollback transaction" );
838- throw new BigQueryJdbcException (ex );
825+ rollbackImpl ();
826+ }
827+ }
828+
829+ private void rollbackImpl () throws SQLException {
830+ try {
831+ QueryJobConfiguration transactionRollbackJobConfig =
832+ QueryJobConfiguration .newBuilder ("ROLLBACK TRANSACTION;" )
833+ .setConnectionProperties (this .queryProperties )
834+ .build ();
835+ Job rollbackJob = this .bigQuery .create (JobInfo .of (transactionRollbackJobConfig ));
836+ rollbackJob .waitFor ();
837+ this .transactionStarted = false ;
838+ if (!getAutoCommit ()) {
839+ beginTransaction ();
839840 }
841+ } catch (InterruptedException | BigQueryException ex ) {
842+ throw new BigQueryJdbcException (ex , "Failed to rollback transaction" );
840843 }
841844 }
842845
@@ -901,36 +904,39 @@ public void close() throws SQLException {
901904 BigQueryJdbcMdc .registerInstance (this , this .connectionId )) {
902905 LOG .finest ("++enter++" );
903906 LOG .fine ("Closing Connection " + this );
907+ closeImpl ();
908+ }
909+ }
904910
905- try {
906- if (this .bigQueryReadClient != null ) {
907- this .bigQueryReadClient .shutdown ();
908- this .bigQueryReadClient .awaitTermination (1 , TimeUnit .MINUTES );
909- this .bigQueryReadClient .close ();
910- }
911+ private void closeImpl () throws SQLException {
912+ try {
913+ if (this .bigQueryReadClient != null ) {
914+ this .bigQueryReadClient .shutdown ();
915+ this .bigQueryReadClient .awaitTermination (1 , TimeUnit .MINUTES );
916+ this .bigQueryReadClient .close ();
917+ }
911918
912- if (this .bigQueryWriteClient != null ) {
913- this .bigQueryWriteClient .shutdown ();
914- this .bigQueryWriteClient .awaitTermination (1 , TimeUnit .MINUTES );
915- this .bigQueryWriteClient .close ();
916- }
919+ if (this .bigQueryWriteClient != null ) {
920+ this .bigQueryWriteClient .shutdown ();
921+ this .bigQueryWriteClient .awaitTermination (1 , TimeUnit .MINUTES );
922+ this .bigQueryWriteClient .close ();
923+ }
917924
918- for (Statement statement : this .openStatements ) {
919- statement .close ();
920- }
921- this .openStatements .clear ();
922- } catch (ConcurrentModificationException ex ) {
923- LOG .severe (ex , "Concurrent modification during close" );
924- throw new BigQueryJdbcException (ex );
925- } catch (InterruptedException e ) {
926- LOG .severe (e , "Interrupted during close" );
927- throw new BigQueryJdbcRuntimeException (e );
928- } finally {
929- BigQueryJdbcMdc .removeInstance (this );
930- BigQueryJdbcRootLogger .closeConnectionHandler (this .connectionId );
925+ for (Statement statement : this .openStatements ) {
926+ statement .close ();
931927 }
932- this .isClosed = true ;
928+ this .openStatements .clear ();
929+ } catch (ConcurrentModificationException ex ) {
930+ LOG .severe (ex , "Concurrent modification during close" );
931+ throw new BigQueryJdbcException (ex );
932+ } catch (InterruptedException e ) {
933+ LOG .severe (e , "Interrupted during close" );
934+ throw new BigQueryJdbcRuntimeException (e );
935+ } finally {
936+ BigQueryJdbcMdc .removeInstance (this );
937+ BigQueryJdbcRootLogger .closeConnectionHandler (this .connectionId );
933938 }
939+ this .isClosed = true ;
934940 }
935941
936942 @ Override
0 commit comments