Skip to content

Commit

Permalink
lint(spanner): Removed unused variables.
Browse files Browse the repository at this point in the history
  • Loading branch information
pratickchokhani committed Dec 9, 2024
1 parent 263901f commit def751b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ public class BatchClientImpl implements BatchClient {
@GuardedBy("multiplexedSessionLock")
private final AtomicReference<SessionImpl> multiplexedSessionReference;

private final Clock clock;

BatchClientImpl(SessionClient sessionClient, boolean isMultiplexedSessionEnabled) {
this.sessionClient = checkNotNull(sessionClient);
this.isMultiplexedSessionEnabled = isMultiplexedSessionEnabled;
Expand All @@ -76,7 +74,6 @@ public class BatchClientImpl implements BatchClient {
// This also ensured that a new session is created on first request.
this.expirationDate = new AtomicReference<>(Instant.MIN);
this.multiplexedSessionReference = new AtomicReference<>();
clock = Clock.systemUTC();
}

@Override
Expand Down Expand Up @@ -137,10 +134,10 @@ public BatchReadOnlyTransaction batchReadOnlyTransaction(BatchTransactionId batc
private SessionImpl getMultiplexedSession() {
this.multiplexedSessionLock.lock();
try {
if (this.clock.instant().isAfter(this.expirationDate.get())
if (Clock.systemUTC().instant().isAfter(this.expirationDate.get())
|| this.multiplexedSessionReference.get() == null) {
this.multiplexedSessionReference.set(this.sessionClient.createMultiplexedSession());
this.expirationDate.set(this.clock.instant().plus(this.sessionExpirationDuration));
this.expirationDate.set(Clock.systemUTC().instant().plus(this.sessionExpirationDuration));
}
return this.multiplexedSessionReference.get();
} finally {
Expand All @@ -151,14 +148,12 @@ private SessionImpl getMultiplexedSession() {
private static class BatchReadOnlyTransactionImpl extends MultiUseReadOnlyTransaction
implements BatchReadOnlyTransaction {
private final String sessionName;
private final boolean isMultiplexedSession;
private final Map<SpannerRpc.Option, ?> options;

BatchReadOnlyTransactionImpl(
MultiUseReadOnlyTransaction.Builder builder, TimestampBound bound) {
super(builder.setTimestampBound(bound));
this.sessionName = session.getName();
this.isMultiplexedSession = session.getIsMultiplexed();
this.options = session.getOptions();
initTransaction();
}
Expand All @@ -168,13 +163,11 @@ private static class BatchReadOnlyTransactionImpl extends MultiUseReadOnlyTransa
super(builder.setTransactionId(batchTransactionId.getTransactionId()));
this.sessionName = session.getName();
this.options = session.getOptions();
this.isMultiplexedSession = session.getIsMultiplexed();
}

@Override
public BatchTransactionId getBatchTransactionId() {
return new BatchTransactionId(
sessionName, getTransactionId(), getReadTimestamp(), session.getIsMultiplexed());
return new BatchTransactionId(sessionName, getTransactionId(), getReadTimestamp());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,7 @@ public class BatchTransactionId implements Serializable {
private final Timestamp timestamp;
private static final long serialVersionUID = 8067099123096783939L;

BatchTransactionId(
String sessionId,
ByteString transactionId,
Timestamp timestamp,
boolean isMultiplexedSession) {
BatchTransactionId(String sessionId, ByteString transactionId, Timestamp timestamp) {
this.transactionId = Preconditions.checkNotNull(transactionId);
this.sessionId = Preconditions.checkNotNull(sessionId);
this.timestamp = Preconditions.checkNotNull(timestamp);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,24 @@ public void equalAndHashCode() {
new EqualsTester()
.addEqualityGroup(
new BatchTransactionId(
"testSession", ByteString.copyFromUtf8("testTxn"), Timestamp.MIN_VALUE, false),
"testSession", ByteString.copyFromUtf8("testTxn"), Timestamp.MIN_VALUE),
new BatchTransactionId(
"testSession", ByteString.copyFromUtf8("testTxn"), Timestamp.MIN_VALUE, false))
"testSession", ByteString.copyFromUtf8("testTxn"), Timestamp.MIN_VALUE))
.addEqualityGroup(
new BatchTransactionId(
"testSession", ByteString.copyFromUtf8("testTxn"), Timestamp.MAX_VALUE, true),
"testSession", ByteString.copyFromUtf8("testTxn"), Timestamp.MAX_VALUE),
new BatchTransactionId(
"testSession", ByteString.copyFromUtf8("testTxn"), Timestamp.MAX_VALUE, true))
"testSession", ByteString.copyFromUtf8("testTxn"), Timestamp.MAX_VALUE))
.testEquals();
}

@Test
public void serialization() {
reserializeAndAssert(
new BatchTransactionId(
"testSession", ByteString.copyFromUtf8("testTxn"), Timestamp.MIN_VALUE, false));
"testSession", ByteString.copyFromUtf8("testTxn"), Timestamp.MIN_VALUE));
reserializeAndAssert(
new BatchTransactionId(
"testSession", ByteString.copyFromUtf8("testTxn"), Timestamp.MIN_VALUE, true));
"testSession", ByteString.copyFromUtf8("testTxn"), Timestamp.MIN_VALUE));
}
}

0 comments on commit def751b

Please sign in to comment.