Skip to content

Commit

Permalink
chore: remove unused code and fix some warnings (#3533)
Browse files Browse the repository at this point in the history
  • Loading branch information
olavloite authored Dec 8, 2024
1 parent 1234447 commit 134be9b
Showing 1 changed file with 8 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@
import io.opentelemetry.api.trace.Span;
import io.opentelemetry.api.trace.Tracer;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.nio.file.Files;
import java.time.Duration;
import java.time.Instant;
import java.util.ArrayList;
Expand All @@ -109,7 +109,6 @@
import java.util.UUID;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.stream.Collectors;
Expand All @@ -130,9 +129,6 @@ class ConnectionImpl implements Connection {
"This method may only be called while in autocommit mode";
private static final String NOT_ALLOWED_IN_AUTOCOMMIT =
"This method may not be called while in autocommit mode";

private static final ParsedStatement BEGIN_STATEMENT =
AbstractStatementParser.getInstance(Dialect.GOOGLE_STANDARD_SQL).parse(Statement.of("BEGIN"));
private static final ParsedStatement COMMIT_STATEMENT =
AbstractStatementParser.getInstance(Dialect.GOOGLE_STANDARD_SQL)
.parse(Statement.of("COMMIT"));
Expand All @@ -145,9 +141,6 @@ class ConnectionImpl implements Connection {
private static final ParsedStatement START_BATCH_DML_STATEMENT =
AbstractStatementParser.getInstance(Dialect.GOOGLE_STANDARD_SQL)
.parse(Statement.of("START BATCH DML"));
private static final ParsedStatement RUN_BATCH_STATEMENT =
AbstractStatementParser.getInstance(Dialect.GOOGLE_STANDARD_SQL)
.parse(Statement.of("RUN BATCH"));

// These SAVEPOINT statements are used as sentinels to recognize the start/rollback/release of a
// savepoint.
Expand Down Expand Up @@ -185,17 +178,6 @@ private LeakedConnectionException() {
private final ConnectionStatementExecutor connectionStatementExecutor =
new ConnectionStatementExecutorImpl(this);

/** Simple thread factory that is used for fire-and-forget rollbacks. */
static final class DaemonThreadFactory implements ThreadFactory {
@Override
public Thread newThread(Runnable r) {
Thread t = new Thread(r);
t.setName("connection-rollback-executor");
t.setDaemon(true);
return t;
}
}

/**
* Statements are executed using a separate thread in order to be able to cancel these. Statements
* are automatically cancelled if the configured {@link ConnectionImpl#statementTimeout} is
Expand Down Expand Up @@ -507,11 +489,6 @@ UnitOfWorkType getUnitOfWorkType() {
return unitOfWorkType;
}

/** Get the current batch mode of this connection. */
BatchMode getBatchMode() {
return batchMode;
}

/** @return <code>true</code> if this connection is in a batch. */
boolean isInBatch() {
return batchMode != BatchMode.NONE;
Expand Down Expand Up @@ -900,7 +877,7 @@ public byte[] getProtoDescriptors() {
String.format(
"File %s is not a valid proto descriptors file", this.protoDescriptorsFilePath));
}
InputStream pdStream = new FileInputStream(protoDescriptorsFile);
InputStream pdStream = Files.newInputStream(protoDescriptorsFile.toPath());
this.protoDescriptors = ByteArray.copyFrom(pdStream).toByteArray();
} catch (Exception exception) {
throw SpannerExceptionFactory.newSpannerException(exception);
Expand Down Expand Up @@ -1420,7 +1397,7 @@ public ResultSet executeQuery(Statement query, QueryOption... options) {

@Override
public AsyncResultSet executeQueryAsync(Statement query, QueryOption... options) {
return parseAndExecuteQueryAsync(CallType.ASYNC, query, AnalyzeMode.NONE, options);
return parseAndExecuteQueryAsync(query, options);
}

@Override
Expand Down Expand Up @@ -1620,8 +1597,7 @@ private ResultSet parseAndExecuteQuery(
+ parsedStatement.getSqlWithoutComments());
}

private AsyncResultSet parseAndExecuteQueryAsync(
CallType callType, Statement query, AnalyzeMode analyzeMode, QueryOption... options) {
private AsyncResultSet parseAndExecuteQueryAsync(Statement query, QueryOption... options) {
Preconditions.checkNotNull(query);
ConnectionPreconditions.checkState(!isClosed(), CLOSED_ERROR_MSG);
ParsedStatement parsedStatement = getStatementParser().parse(query, buildQueryOptions());
Expand All @@ -1636,7 +1612,8 @@ private AsyncResultSet parseAndExecuteQueryAsync(
spanner.getAsyncExecutorProvider(),
options);
case QUERY:
return internalExecuteQueryAsync(callType, parsedStatement, analyzeMode, options);
return internalExecuteQueryAsync(
CallType.ASYNC, parsedStatement, AnalyzeMode.NONE, options);
case UPDATE:
if (parsedStatement.hasReturningClause()) {
// Cannot execute DML statement with returning clause in read-only mode or in
Expand All @@ -1649,7 +1626,8 @@ private AsyncResultSet parseAndExecuteQueryAsync(
"DML statement with returning clause cannot be executed in read-only mode: "
+ parsedStatement.getSqlWithoutComments());
}
return internalExecuteQueryAsync(callType, parsedStatement, analyzeMode, options);
return internalExecuteQueryAsync(
CallType.ASYNC, parsedStatement, AnalyzeMode.NONE, options);
}
case DDL:
case UNKNOWN:
Expand Down

0 comments on commit 134be9b

Please sign in to comment.