@@ -964,14 +964,38 @@ private void closeImpl() throws SQLException {
964964
965965 if (this .metadataExecutor != null ) {
966966 this .metadataExecutor .shutdown ();
967- this .metadataExecutor .awaitTermination (10 , TimeUnit .SECONDS );
968- this .metadataExecutor .shutdownNow ();
969967 }
970-
971968 if (this .queryExecutor != null ) {
972969 this .queryExecutor .shutdown ();
973- this .queryExecutor .awaitTermination (10 , TimeUnit .SECONDS );
974- this .queryExecutor .shutdownNow ();
970+ }
971+
972+ boolean interrupted = false ;
973+
974+ if (this .metadataExecutor != null ) {
975+ try {
976+ if (!this .metadataExecutor .awaitTermination (10 , TimeUnit .SECONDS )) {
977+ this .metadataExecutor .shutdownNow ();
978+ }
979+ } catch (InterruptedException e ) {
980+ this .metadataExecutor .shutdownNow ();
981+ interrupted = true ;
982+ }
983+ }
984+
985+ if (this .queryExecutor != null ) {
986+ try {
987+ if (!this .queryExecutor .awaitTermination (10 , TimeUnit .SECONDS )) {
988+ this .queryExecutor .shutdownNow ();
989+ }
990+ } catch (InterruptedException e ) {
991+ this .queryExecutor .shutdownNow ();
992+ interrupted = true ;
993+ }
994+ }
995+
996+ if (interrupted ) {
997+ Thread .currentThread ().interrupt ();
998+ throw new InterruptedException ("Interrupted awaiting executor termination" );
975999 }
9761000 } catch (ConcurrentModificationException ex ) {
9771001 throw new BigQueryJdbcException ("Concurrent modification during close" , ex );
0 commit comments