Skip to content

Commit 40cc065

Browse files
spkrkasduskis
authored andcommitted
---
yaml --- r: 25459 b: refs/heads/autosynth-texttospeech c: 03ba9c9 h: refs/heads/master i: 25457: fd9f430 25455: ad4fa75
1 parent c39d047 commit 40cc065

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
@@ -140,7 +140,7 @@ refs/heads/autosynth-scheduler: 57f9fdb1e7de30c85f4ec7198931a07f50603e55
140140
refs/heads/autosynth-spanner: cbd30ccc550e9d0419ce4e5e6cfef4951ea170b1
141141
refs/heads/autosynth-speech: 64692f6db11364f663921be02c08072b966b6e7b
142142
refs/heads/autosynth-tasks: eb03eeab747e925175890db923945384d89b273a
143-
refs/heads/autosynth-texttospeech: 0a6fc39ab502f112b3cbdd671d8c79189c51bcdf
143+
refs/heads/autosynth-texttospeech: 03ba9c91cab9113f30bfc43d185fc87d1b515303
144144
refs/heads/autosynth-trace: 8804c46bfe147702ee9c95669f17f42d3790cf23
145145
refs/heads/autosynth-websecurityscanner: a3c778316a0f78f7ad4bac3dc3721da5ca832d3c
146146
refs/heads/bigquerystorage: 06db74d123d7f8a3ef48755c2fcabed09faf8e64

branches/autosynth-texttospeech/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-texttospeech/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)