Skip to content

Commit 82d161f

Browse files
spkrkasduskis
authored andcommitted
---
yaml --- r: 23095 b: refs/heads/autosynth-containeranalysis c: 03ba9c9 h: refs/heads/master i: 23093: 7065d9c 23091: c3ca815 23087: 89d3cdc
1 parent cd677c2 commit 82d161f

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
@@ -126,7 +126,7 @@ refs/heads/autosynth-bigquerydatatransfer: d88aa5aae5fd9d3c6d75bbab1a05162c6d4d9
126126
refs/heads/autosynth-bigquerystorage: d2c53da3b012e38c662e4df0738042435f19365f
127127
refs/heads/autosynth-bigtable: 9e5429f45cf9face9fed585d0233534993e36b58
128128
refs/heads/autosynth-bigtable-admin: 6379a2bc712f2736c83de0e009b4d26da4fa82ca
129-
refs/heads/autosynth-containeranalysis: 0a6fc39ab502f112b3cbdd671d8c79189c51bcdf
129+
refs/heads/autosynth-containeranalysis: 03ba9c91cab9113f30bfc43d185fc87d1b515303
130130
refs/heads/autosynth-datastore: 9acd400b484d6691a080c9152a331d88d24fefc1
131131
refs/heads/autosynth-dialogflow: 7dbc2c1ea714328ccfa4f33645045f017ff080e7
132132
refs/heads/autosynth-errorreporting: 1101a04e8be074802c35332d5fcf8297f61cae32

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