9494import io .opentelemetry .api .trace .Span ;
9595import io .opentelemetry .api .trace .Tracer ;
9696import java .io .File ;
97- import java .io .FileInputStream ;
9897import java .io .InputStream ;
98+ import java .nio .file .Files ;
9999import java .time .Duration ;
100100import java .time .Instant ;
101101import java .util .ArrayList ;
109109import java .util .UUID ;
110110import java .util .concurrent .ExecutionException ;
111111import java .util .concurrent .RejectedExecutionException ;
112- import java .util .concurrent .ThreadFactory ;
113112import java .util .concurrent .TimeUnit ;
114113import java .util .concurrent .TimeoutException ;
115114import java .util .stream .Collectors ;
@@ -130,9 +129,6 @@ class ConnectionImpl implements Connection {
130129 "This method may only be called while in autocommit mode" ;
131130 private static final String NOT_ALLOWED_IN_AUTOCOMMIT =
132131 "This method may not be called while in autocommit mode" ;
133-
134- private static final ParsedStatement BEGIN_STATEMENT =
135- AbstractStatementParser .getInstance (Dialect .GOOGLE_STANDARD_SQL ).parse (Statement .of ("BEGIN" ));
136132 private static final ParsedStatement COMMIT_STATEMENT =
137133 AbstractStatementParser .getInstance (Dialect .GOOGLE_STANDARD_SQL )
138134 .parse (Statement .of ("COMMIT" ));
@@ -145,9 +141,6 @@ class ConnectionImpl implements Connection {
145141 private static final ParsedStatement START_BATCH_DML_STATEMENT =
146142 AbstractStatementParser .getInstance (Dialect .GOOGLE_STANDARD_SQL )
147143 .parse (Statement .of ("START BATCH DML" ));
148- private static final ParsedStatement RUN_BATCH_STATEMENT =
149- AbstractStatementParser .getInstance (Dialect .GOOGLE_STANDARD_SQL )
150- .parse (Statement .of ("RUN BATCH" ));
151144
152145 // These SAVEPOINT statements are used as sentinels to recognize the start/rollback/release of a
153146 // savepoint.
@@ -185,17 +178,6 @@ private LeakedConnectionException() {
185178 private final ConnectionStatementExecutor connectionStatementExecutor =
186179 new ConnectionStatementExecutorImpl (this );
187180
188- /** Simple thread factory that is used for fire-and-forget rollbacks. */
189- static final class DaemonThreadFactory implements ThreadFactory {
190- @ Override
191- public Thread newThread (Runnable r ) {
192- Thread t = new Thread (r );
193- t .setName ("connection-rollback-executor" );
194- t .setDaemon (true );
195- return t ;
196- }
197- }
198-
199181 /**
200182 * Statements are executed using a separate thread in order to be able to cancel these. Statements
201183 * are automatically cancelled if the configured {@link ConnectionImpl#statementTimeout} is
@@ -507,11 +489,6 @@ UnitOfWorkType getUnitOfWorkType() {
507489 return unitOfWorkType ;
508490 }
509491
510- /** Get the current batch mode of this connection. */
511- BatchMode getBatchMode () {
512- return batchMode ;
513- }
514-
515492 /** @return <code>true</code> if this connection is in a batch. */
516493 boolean isInBatch () {
517494 return batchMode != BatchMode .NONE ;
@@ -900,7 +877,7 @@ public byte[] getProtoDescriptors() {
900877 String .format (
901878 "File %s is not a valid proto descriptors file" , this .protoDescriptorsFilePath ));
902879 }
903- InputStream pdStream = new FileInputStream (protoDescriptorsFile );
880+ InputStream pdStream = Files . newInputStream (protoDescriptorsFile . toPath () );
904881 this .protoDescriptors = ByteArray .copyFrom (pdStream ).toByteArray ();
905882 } catch (Exception exception ) {
906883 throw SpannerExceptionFactory .newSpannerException (exception );
@@ -1420,7 +1397,7 @@ public ResultSet executeQuery(Statement query, QueryOption... options) {
14201397
14211398 @ Override
14221399 public AsyncResultSet executeQueryAsync (Statement query , QueryOption ... options ) {
1423- return parseAndExecuteQueryAsync (CallType . ASYNC , query , AnalyzeMode . NONE , options );
1400+ return parseAndExecuteQueryAsync (query , options );
14241401 }
14251402
14261403 @ Override
@@ -1620,8 +1597,7 @@ private ResultSet parseAndExecuteQuery(
16201597 + parsedStatement .getSqlWithoutComments ());
16211598 }
16221599
1623- private AsyncResultSet parseAndExecuteQueryAsync (
1624- CallType callType , Statement query , AnalyzeMode analyzeMode , QueryOption ... options ) {
1600+ private AsyncResultSet parseAndExecuteQueryAsync (Statement query , QueryOption ... options ) {
16251601 Preconditions .checkNotNull (query );
16261602 ConnectionPreconditions .checkState (!isClosed (), CLOSED_ERROR_MSG );
16271603 ParsedStatement parsedStatement = getStatementParser ().parse (query , buildQueryOptions ());
@@ -1636,7 +1612,8 @@ private AsyncResultSet parseAndExecuteQueryAsync(
16361612 spanner .getAsyncExecutorProvider (),
16371613 options );
16381614 case QUERY :
1639- return internalExecuteQueryAsync (callType , parsedStatement , analyzeMode , options );
1615+ return internalExecuteQueryAsync (
1616+ CallType .ASYNC , parsedStatement , AnalyzeMode .NONE , options );
16401617 case UPDATE :
16411618 if (parsedStatement .hasReturningClause ()) {
16421619 // Cannot execute DML statement with returning clause in read-only mode or in
@@ -1649,7 +1626,8 @@ private AsyncResultSet parseAndExecuteQueryAsync(
16491626 "DML statement with returning clause cannot be executed in read-only mode: "
16501627 + parsedStatement .getSqlWithoutComments ());
16511628 }
1652- return internalExecuteQueryAsync (callType , parsedStatement , analyzeMode , options );
1629+ return internalExecuteQueryAsync (
1630+ CallType .ASYNC , parsedStatement , AnalyzeMode .NONE , options );
16531631 }
16541632 case DDL :
16551633 case UNKNOWN :
0 commit comments