Skip to content

Commit e470198

Browse files
spkrkasduskis
authored andcommitted
---
yaml --- r: 25211 b: refs/heads/autosynth-tasks c: 03ba9c9 h: refs/heads/master i: 25209: 7f9038f 25207: 702d5c8
1 parent 0ae5239 commit e470198

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
@@ -139,7 +139,7 @@ refs/heads/autosynth-redis: 6bedce4d7c7c6ca6a22e83ad1780e08fdc565a9e
139139
refs/heads/autosynth-scheduler: 57f9fdb1e7de30c85f4ec7198931a07f50603e55
140140
refs/heads/autosynth-spanner: cbd30ccc550e9d0419ce4e5e6cfef4951ea170b1
141141
refs/heads/autosynth-speech: 64692f6db11364f663921be02c08072b966b6e7b
142-
refs/heads/autosynth-tasks: 0a6fc39ab502f112b3cbdd671d8c79189c51bcdf
142+
refs/heads/autosynth-tasks: 03ba9c91cab9113f30bfc43d185fc87d1b515303
143143
refs/heads/autosynth-texttospeech: 2dcc5dc22be0f456caa1b6a8a4bcdace2641239c
144144
refs/heads/autosynth-trace: 8804c46bfe147702ee9c95669f17f42d3790cf23
145145
refs/heads/autosynth-websecurityscanner: a3c778316a0f78f7ad4bac3dc3721da5ca832d3c

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