94
94
import io .opentelemetry .api .trace .Span ;
95
95
import io .opentelemetry .api .trace .Tracer ;
96
96
import java .io .File ;
97
- import java .io .FileInputStream ;
98
97
import java .io .InputStream ;
98
+ import java .nio .file .Files ;
99
99
import java .time .Duration ;
100
100
import java .time .Instant ;
101
101
import java .util .ArrayList ;
109
109
import java .util .UUID ;
110
110
import java .util .concurrent .ExecutionException ;
111
111
import java .util .concurrent .RejectedExecutionException ;
112
- import java .util .concurrent .ThreadFactory ;
113
112
import java .util .concurrent .TimeUnit ;
114
113
import java .util .concurrent .TimeoutException ;
115
114
import java .util .stream .Collectors ;
@@ -130,9 +129,6 @@ class ConnectionImpl implements Connection {
130
129
"This method may only be called while in autocommit mode" ;
131
130
private static final String NOT_ALLOWED_IN_AUTOCOMMIT =
132
131
"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" ));
136
132
private static final ParsedStatement COMMIT_STATEMENT =
137
133
AbstractStatementParser .getInstance (Dialect .GOOGLE_STANDARD_SQL )
138
134
.parse (Statement .of ("COMMIT" ));
@@ -145,9 +141,6 @@ class ConnectionImpl implements Connection {
145
141
private static final ParsedStatement START_BATCH_DML_STATEMENT =
146
142
AbstractStatementParser .getInstance (Dialect .GOOGLE_STANDARD_SQL )
147
143
.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" ));
151
144
152
145
// These SAVEPOINT statements are used as sentinels to recognize the start/rollback/release of a
153
146
// savepoint.
@@ -185,17 +178,6 @@ private LeakedConnectionException() {
185
178
private final ConnectionStatementExecutor connectionStatementExecutor =
186
179
new ConnectionStatementExecutorImpl (this );
187
180
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
-
199
181
/**
200
182
* Statements are executed using a separate thread in order to be able to cancel these. Statements
201
183
* are automatically cancelled if the configured {@link ConnectionImpl#statementTimeout} is
@@ -507,11 +489,6 @@ UnitOfWorkType getUnitOfWorkType() {
507
489
return unitOfWorkType ;
508
490
}
509
491
510
- /** Get the current batch mode of this connection. */
511
- BatchMode getBatchMode () {
512
- return batchMode ;
513
- }
514
-
515
492
/** @return <code>true</code> if this connection is in a batch. */
516
493
boolean isInBatch () {
517
494
return batchMode != BatchMode .NONE ;
@@ -900,7 +877,7 @@ public byte[] getProtoDescriptors() {
900
877
String .format (
901
878
"File %s is not a valid proto descriptors file" , this .protoDescriptorsFilePath ));
902
879
}
903
- InputStream pdStream = new FileInputStream (protoDescriptorsFile );
880
+ InputStream pdStream = Files . newInputStream (protoDescriptorsFile . toPath () );
904
881
this .protoDescriptors = ByteArray .copyFrom (pdStream ).toByteArray ();
905
882
} catch (Exception exception ) {
906
883
throw SpannerExceptionFactory .newSpannerException (exception );
@@ -1420,7 +1397,7 @@ public ResultSet executeQuery(Statement query, QueryOption... options) {
1420
1397
1421
1398
@ Override
1422
1399
public AsyncResultSet executeQueryAsync (Statement query , QueryOption ... options ) {
1423
- return parseAndExecuteQueryAsync (CallType . ASYNC , query , AnalyzeMode . NONE , options );
1400
+ return parseAndExecuteQueryAsync (query , options );
1424
1401
}
1425
1402
1426
1403
@ Override
@@ -1620,8 +1597,7 @@ private ResultSet parseAndExecuteQuery(
1620
1597
+ parsedStatement .getSqlWithoutComments ());
1621
1598
}
1622
1599
1623
- private AsyncResultSet parseAndExecuteQueryAsync (
1624
- CallType callType , Statement query , AnalyzeMode analyzeMode , QueryOption ... options ) {
1600
+ private AsyncResultSet parseAndExecuteQueryAsync (Statement query , QueryOption ... options ) {
1625
1601
Preconditions .checkNotNull (query );
1626
1602
ConnectionPreconditions .checkState (!isClosed (), CLOSED_ERROR_MSG );
1627
1603
ParsedStatement parsedStatement = getStatementParser ().parse (query , buildQueryOptions ());
@@ -1636,7 +1612,8 @@ private AsyncResultSet parseAndExecuteQueryAsync(
1636
1612
spanner .getAsyncExecutorProvider (),
1637
1613
options );
1638
1614
case QUERY :
1639
- return internalExecuteQueryAsync (callType , parsedStatement , analyzeMode , options );
1615
+ return internalExecuteQueryAsync (
1616
+ CallType .ASYNC , parsedStatement , AnalyzeMode .NONE , options );
1640
1617
case UPDATE :
1641
1618
if (parsedStatement .hasReturningClause ()) {
1642
1619
// Cannot execute DML statement with returning clause in read-only mode or in
@@ -1649,7 +1626,8 @@ private AsyncResultSet parseAndExecuteQueryAsync(
1649
1626
"DML statement with returning clause cannot be executed in read-only mode: "
1650
1627
+ parsedStatement .getSqlWithoutComments ());
1651
1628
}
1652
- return internalExecuteQueryAsync (callType , parsedStatement , analyzeMode , options );
1629
+ return internalExecuteQueryAsync (
1630
+ CallType .ASYNC , parsedStatement , AnalyzeMode .NONE , options );
1653
1631
}
1654
1632
case DDL :
1655
1633
case UNKNOWN :
0 commit comments