Skip to content

Commit 0475ca8

Browse files
spkrkasduskis
authored andcommitted
---
yaml --- r: 23977 b: refs/heads/autosynth-kms c: 03ba9c9 h: refs/heads/master i: 23975: cab7b05
1 parent f4903d3 commit 0475ca8

3 files changed

Lines changed: 13 additions & 4 deletions

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ refs/heads/autosynth-dialogflow: cb1ceeb3ec1a132d3096fc88d44b930a52130e18
132132
refs/heads/autosynth-errorreporting: 3f176c20b55dfaaa8fc32f28d82b31784b93e636
133133
refs/heads/autosynth-firestore: d48d82caace227856b6cd85ac30ee474528733ea
134134
refs/heads/autosynth-iot: 4025d1804241e74d54950a324dc4f667aeaad4b3
135-
refs/heads/autosynth-kms: 0a6fc39ab502f112b3cbdd671d8c79189c51bcdf
135+
refs/heads/autosynth-kms: 03ba9c91cab9113f30bfc43d185fc87d1b515303
136136
refs/heads/autosynth-language: c3d990dd34d81e7e935041e7147fb9dd27f8a557
137137
refs/heads/autosynth-os-login: 092fdbed6d5317948f92b708e9f50dedd89fc666
138138
refs/heads/autosynth-redis: 9e1fe503973c7b4a9ba26afb1fcddc2a57ba795a

branches/autosynth-kms/google-cloud-clients/google-cloud-logging/src/main/java/com/google/cloud/logging/LoggingImpl.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import com.google.cloud.MonitoredResourceDescriptor;
3838
import com.google.cloud.PageImpl;
3939
import com.google.cloud.logging.spi.v2.LoggingRpc;
40+
import com.google.common.annotations.VisibleForTesting;
4041
import com.google.common.base.Function;
4142
import com.google.common.base.Throwables;
4243
import com.google.common.collect.ImmutableList;
@@ -595,6 +596,9 @@ private void writeLogEntries(Iterable<LogEntry> logEntries, WriteOption... write
595596
case ASYNC:
596597
default:
597598
final ApiFuture<Void> writeFuture = writeAsync(logEntries, writeOptions);
599+
synchronized (writeLock) {
600+
pendingWrites.add(writeFuture);
601+
}
598602
ApiFutures.addCallback(
599603
writeFuture,
600604
new ApiFutureCallback<Void>() {
@@ -619,9 +623,6 @@ public void onFailure(Throwable t) {
619623
}
620624
}
621625
});
622-
synchronized (writeLock) {
623-
pendingWrites.add(writeFuture);
624-
}
625626
break;
626627
}
627628
}
@@ -707,4 +708,11 @@ public void close() throws Exception {
707708
}
708709
return optionMap;
709710
}
711+
712+
@VisibleForTesting
713+
int getNumPendingWrites() {
714+
synchronized (writeLock) {
715+
return pendingWrites.size();
716+
}
717+
}
710718
}

branches/autosynth-kms/google-cloud-clients/google-cloud-logging/src/test/java/com/google/cloud/logging/LoggingImplTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,6 +1186,7 @@ public void testWriteLogEntries() {
11861186
EasyMock.replay(rpcFactoryMock, loggingRpcMock);
11871187
logging = options.getService();
11881188
logging.write(ImmutableList.of(LOG_ENTRY1, LOG_ENTRY2));
1189+
assertEquals(0, ((LoggingImpl) logging).getNumPendingWrites());
11891190
}
11901191

11911192
@Test

0 commit comments

Comments
 (0)