Program: 93024
Project: 93024
Buggy source:
@Test public void testWriteAndListLogEntries() throws InterruptedException {
  String logName=formatForTest("String_Node_Str");
  String filter="String_Node_Str" + logging().getOptions().getProjectId() + "String_Node_Str"+ logName;
  StringPayload firstPayload=StringPayload.of("String_Node_Str");
  LogEntry firstEntry=LogEntry.newBuilder(firstPayload).addLabel("String_Node_Str","String_Node_Str").setLogName(logName).setHttpRequest(HttpRequest.newBuilder().setStatus(500).build()).setResource(MonitoredResource.newBuilder("String_Node_Str").build()).build();
  JsonPayload secondPayload=JsonPayload.of(ImmutableMap.<String,Object>of("String_Node_Str","String_Node_Str"));
  LogEntry secondEntry=LogEntry.newBuilder(secondPayload).addLabel("String_Node_Str","String_Node_Str").setLogName(logName).setOperation(Operation.of("String_Node_Str","String_Node_Str")).setResource(MonitoredResource.newBuilder("String_Node_Str").build()).build();
  logging().write(ImmutableList.of(firstEntry));
  logging().write(ImmutableList.of(secondEntry));
  EntryListOption[] options={EntryListOption.filter(filter),EntryListOption.pageSize(1)};
  Page<LogEntry> page=logging().listLogEntries(options);
  while (Iterators.size(page.iterateAll().iterator()) < 2) {
    Thread.sleep(500);
    page=logging().listLogEntries(options);
  }
  Iterator<LogEntry> iterator=page.iterateAll().iterator();
  assertTrue(iterator.hasNext());
  LogEntry entry=iterator.next();
  assertEquals(firstPayload,entry.getPayload());
  assertEquals(logName,entry.getLogName());
  assertEquals(ImmutableMap.of("String_Node_Str","String_Node_Str"),entry.getLabels());
  assertEquals("String_Node_Str",entry.getResource().getType());
  assertEquals(HttpRequest.newBuilder().setStatus(500).build(),entry.getHttpRequest());
  assertEquals(Severity.DEFAULT,entry.getSeverity());
  assertNull(entry.getOperation());
  assertNotNull(entry.getInsertId());
  assertNotNull(entry.getTimestamp());
  assertTrue(iterator.hasNext());
  entry=iterator.next();
  assertEquals(secondPayload,entry.getPayload());
  assertEquals(logName,entry.getLogName());
  assertEquals(ImmutableMap.of("String_Node_Str","String_Node_Str"),entry.getLabels());
  assertEquals("String_Node_Str",entry.getResource().getType());
  assertEquals(Operation.of("String_Node_Str","String_Node_Str"),entry.getOperation());
  assertEquals(Severity.DEFAULT,entry.getSeverity());
  assertNull(entry.getHttpRequest());
  assertNotNull(entry.getInsertId());
  assertNotNull(entry.getTimestamp());
  options=new EntryListOption[]{EntryListOption.filter(filter),EntryListOption.sortOrder(SortingField.TIMESTAMP,SortingOrder.DESCENDING)};
  page=logging().listLogEntries(options);
  while (Iterators.size(page.iterateAll().iterator()) < 2) {
    Thread.sleep(500);
    page=logging().listLogEntries(options);
  }
  iterator=page.iterateAll().iterator();
  Long lastTimestamp=iterator.next().getTimestamp();
  while (iterator.hasNext()) {
    assertTrue(iterator.next().getTimestamp() <= lastTimestamp);
  }
  assertTrue(logging().deleteLog(logName));
}

Fixed version (ground truth):
@Test public void testWriteAndListLogEntries() throws InterruptedException {
  String logId=formatForTest("String_Node_Str");
  LoggingOptions loggingOptions=logging().getOptions();
  LogName logName=LogName.create(loggingOptions.getProjectId(),logId);
  StringPayload firstPayload=StringPayload.of("String_Node_Str");
  LogEntry firstEntry=LogEntry.newBuilder(firstPayload).addLabel("String_Node_Str","String_Node_Str").setLogName(logId).setHttpRequest(HttpRequest.newBuilder().setStatus(500).build()).setResource(MonitoredResource.newBuilder("String_Node_Str").build()).build();
  JsonPayload secondPayload=JsonPayload.of(ImmutableMap.<String,Object>of("String_Node_Str","String_Node_Str"));
  LogEntry secondEntry=LogEntry.newBuilder(secondPayload).addLabel("String_Node_Str","String_Node_Str").setLogName(logId).setOperation(Operation.of("String_Node_Str","String_Node_Str")).setResource(MonitoredResource.newBuilder("String_Node_Str").build()).build();
  logging().write(ImmutableList.of(firstEntry));
  logging().write(ImmutableList.of(secondEntry));
  String filter=createEqualityFilter("String_Node_Str",logName);
  EntryListOption[] options={EntryListOption.filter(filter),EntryListOption.pageSize(1)};
  Page<LogEntry> page=logging().listLogEntries(options);
  while (Iterators.size(page.iterateAll().iterator()) < 2) {
    Thread.sleep(500);
    page=logging().listLogEntries(options);
  }
  Iterator<LogEntry> iterator=page.iterateAll().iterator();
  assertTrue(iterator.hasNext());
  LogEntry entry=iterator.next();
  assertEquals(firstPayload,entry.getPayload());
  assertEquals(logId,entry.getLogName());
  assertEquals(ImmutableMap.of("String_Node_Str","String_Node_Str"),entry.getLabels());
  assertEquals("String_Node_Str",entry.getResource().getType());
  assertEquals(HttpRequest.newBuilder().setStatus(500).build(),entry.getHttpRequest());
  assertEquals(Severity.DEFAULT,entry.getSeverity());
  assertNull(entry.getOperation());
  assertNotNull(entry.getInsertId());
  assertNotNull(entry.getTimestamp());
  assertTrue(iterator.hasNext());
  entry=iterator.next();
  assertEquals(secondPayload,entry.getPayload());
  assertEquals(logId,entry.getLogName());
  assertEquals(ImmutableMap.of("String_Node_Str","String_Node_Str"),entry.getLabels());
  assertEquals("String_Node_Str",entry.getResource().getType());
  assertEquals(Operation.of("String_Node_Str","String_Node_Str"),entry.getOperation());
  assertEquals(Severity.DEFAULT,entry.getSeverity());
  assertNull(entry.getHttpRequest());
  assertNotNull(entry.getInsertId());
  assertNotNull(entry.getTimestamp());
  options=new EntryListOption[]{EntryListOption.filter(filter),EntryListOption.sortOrder(SortingField.TIMESTAMP,SortingOrder.DESCENDING)};
  page=logging().listLogEntries(options);
  while (Iterators.size(page.iterateAll().iterator()) < 2) {
    Thread.sleep(500);
    page=logging().listLogEntries(options);
  }
  iterator=page.iterateAll().iterator();
  Long lastTimestamp=iterator.next().getTimestamp();
  while (iterator.hasNext()) {
    assertTrue(iterator.next().getTimestamp() <= lastTimestamp);
  }
  assertTrue(logging().deleteLog(logId));
}