Skip to content

Commit def751b

Browse files
lint(spanner): Removed unused variables.
1 parent 263901f commit def751b

File tree

3 files changed

+10
-21
lines changed

3 files changed

+10
-21
lines changed

google-cloud-spanner/src/main/java/com/google/cloud/spanner/BatchClientImpl.java

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@ public class BatchClientImpl implements BatchClient {
5959
@GuardedBy("multiplexedSessionLock")
6060
private final AtomicReference<SessionImpl> multiplexedSessionReference;
6161

62-
private final Clock clock;
63-
6462
BatchClientImpl(SessionClient sessionClient, boolean isMultiplexedSessionEnabled) {
6563
this.sessionClient = checkNotNull(sessionClient);
6664
this.isMultiplexedSessionEnabled = isMultiplexedSessionEnabled;
@@ -76,7 +74,6 @@ public class BatchClientImpl implements BatchClient {
7674
// This also ensured that a new session is created on first request.
7775
this.expirationDate = new AtomicReference<>(Instant.MIN);
7876
this.multiplexedSessionReference = new AtomicReference<>();
79-
clock = Clock.systemUTC();
8077
}
8178

8279
@Override
@@ -137,10 +134,10 @@ public BatchReadOnlyTransaction batchReadOnlyTransaction(BatchTransactionId batc
137134
private SessionImpl getMultiplexedSession() {
138135
this.multiplexedSessionLock.lock();
139136
try {
140-
if (this.clock.instant().isAfter(this.expirationDate.get())
137+
if (Clock.systemUTC().instant().isAfter(this.expirationDate.get())
141138
|| this.multiplexedSessionReference.get() == null) {
142139
this.multiplexedSessionReference.set(this.sessionClient.createMultiplexedSession());
143-
this.expirationDate.set(this.clock.instant().plus(this.sessionExpirationDuration));
140+
this.expirationDate.set(Clock.systemUTC().instant().plus(this.sessionExpirationDuration));
144141
}
145142
return this.multiplexedSessionReference.get();
146143
} finally {
@@ -151,14 +148,12 @@ private SessionImpl getMultiplexedSession() {
151148
private static class BatchReadOnlyTransactionImpl extends MultiUseReadOnlyTransaction
152149
implements BatchReadOnlyTransaction {
153150
private final String sessionName;
154-
private final boolean isMultiplexedSession;
155151
private final Map<SpannerRpc.Option, ?> options;
156152

157153
BatchReadOnlyTransactionImpl(
158154
MultiUseReadOnlyTransaction.Builder builder, TimestampBound bound) {
159155
super(builder.setTimestampBound(bound));
160156
this.sessionName = session.getName();
161-
this.isMultiplexedSession = session.getIsMultiplexed();
162157
this.options = session.getOptions();
163158
initTransaction();
164159
}
@@ -168,13 +163,11 @@ private static class BatchReadOnlyTransactionImpl extends MultiUseReadOnlyTransa
168163
super(builder.setTransactionId(batchTransactionId.getTransactionId()));
169164
this.sessionName = session.getName();
170165
this.options = session.getOptions();
171-
this.isMultiplexedSession = session.getIsMultiplexed();
172166
}
173167

174168
@Override
175169
public BatchTransactionId getBatchTransactionId() {
176-
return new BatchTransactionId(
177-
sessionName, getTransactionId(), getReadTimestamp(), session.getIsMultiplexed());
170+
return new BatchTransactionId(sessionName, getTransactionId(), getReadTimestamp());
178171
}
179172

180173
@Override

google-cloud-spanner/src/main/java/com/google/cloud/spanner/BatchTransactionId.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,7 @@ public class BatchTransactionId implements Serializable {
3434
private final Timestamp timestamp;
3535
private static final long serialVersionUID = 8067099123096783939L;
3636

37-
BatchTransactionId(
38-
String sessionId,
39-
ByteString transactionId,
40-
Timestamp timestamp,
41-
boolean isMultiplexedSession) {
37+
BatchTransactionId(String sessionId, ByteString transactionId, Timestamp timestamp) {
4238
this.transactionId = Preconditions.checkNotNull(transactionId);
4339
this.sessionId = Preconditions.checkNotNull(sessionId);
4440
this.timestamp = Preconditions.checkNotNull(timestamp);

google-cloud-spanner/src/test/java/com/google/cloud/spanner/BatchTransactionIdTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,24 @@ public void equalAndHashCode() {
3434
new EqualsTester()
3535
.addEqualityGroup(
3636
new BatchTransactionId(
37-
"testSession", ByteString.copyFromUtf8("testTxn"), Timestamp.MIN_VALUE, false),
37+
"testSession", ByteString.copyFromUtf8("testTxn"), Timestamp.MIN_VALUE),
3838
new BatchTransactionId(
39-
"testSession", ByteString.copyFromUtf8("testTxn"), Timestamp.MIN_VALUE, false))
39+
"testSession", ByteString.copyFromUtf8("testTxn"), Timestamp.MIN_VALUE))
4040
.addEqualityGroup(
4141
new BatchTransactionId(
42-
"testSession", ByteString.copyFromUtf8("testTxn"), Timestamp.MAX_VALUE, true),
42+
"testSession", ByteString.copyFromUtf8("testTxn"), Timestamp.MAX_VALUE),
4343
new BatchTransactionId(
44-
"testSession", ByteString.copyFromUtf8("testTxn"), Timestamp.MAX_VALUE, true))
44+
"testSession", ByteString.copyFromUtf8("testTxn"), Timestamp.MAX_VALUE))
4545
.testEquals();
4646
}
4747

4848
@Test
4949
public void serialization() {
5050
reserializeAndAssert(
5151
new BatchTransactionId(
52-
"testSession", ByteString.copyFromUtf8("testTxn"), Timestamp.MIN_VALUE, false));
52+
"testSession", ByteString.copyFromUtf8("testTxn"), Timestamp.MIN_VALUE));
5353
reserializeAndAssert(
5454
new BatchTransactionId(
55-
"testSession", ByteString.copyFromUtf8("testTxn"), Timestamp.MIN_VALUE, true));
55+
"testSession", ByteString.copyFromUtf8("testTxn"), Timestamp.MIN_VALUE));
5656
}
5757
}

0 commit comments

Comments
 (0)