Program: 53029
Project: 53029
Buggy source:
@Test public void sendStoredLogs() throws Exception {
  final ImmutableList<String> blacklistCategories=ImmutableList.of();
  final int maxScribeOfflineLogsKB=2;
  final ProjectFilesystem filesystem=new ProjectFilesystem(tmp.getRoot());
  final Path logDir=filesystem.getBuckPaths().getOfflineLogDir();
  final ObjectMapper objectMapper=ObjectMappers.newDefaultInstance();
  final String[] ids={"String_Node_Str","String_Node_Str","String_Node_Str"};
  final String[] uniqueCategories={"String_Node_Str","String_Node_Str"};
  final String[] categories={uniqueCategories[0],uniqueCategories[1],uniqueCategories[0]};
  final String testCategory="String_Node_Str";
  final String line="String_Node_Str";
  final List<Pair<String,Iterable<String>>> sentData=new ArrayList<>();
  final ScribeLogger succeeddingLogger=new ScribeLogger(){
    @Override public ListenableFuture<Void> log(    String category,    Iterable<String> lines){
      if (!category.equals(testCategory)) {
        sentData.add(new Pair<>(category,lines));
      }
      return Futures.immediateFuture(null);
    }
    @Override public void close() throws Exception {
    }
  }
;
  filesystem.mkdirs(logDir);
  for (  String id : ids) {
    File log=filesystem.resolve(logDir.resolve(LOGFILE_PREFIX + id + LOGFILE_SUFFIX)).toFile();
    BufferedOutputStream logFileStoreStream=new BufferedOutputStream(new FileOutputStream(log));
    for (    String category : categories) {
      byte[] scribeData=objectMapper.writeValueAsString(ScribeData.builder().setCategory(category).setLines(ImmutableList.of(line,line,line,line)).build()).getBytes(Charsets.UTF_8);
      logFileStoreStream.write(scribeData);
    }
    logFileStoreStream.close();
  }
  OfflineScribeLogger offlineLogger=new OfflineScribeLogger(succeeddingLogger,blacklistCategories,maxScribeOfflineLogsKB,filesystem,objectMapper,BuckEventBusFactory.newInstance(),new BuildId("String_Node_Str"));
  offlineLogger.log(testCategory,ImmutableList.of("String_Node_Str","String_Node_Str"));
  offlineLogger.close();
  assertEquals(4,sentData.size());
  final String[] expectedCategories=ObjectArrays.concat(uniqueCategories,uniqueCategories,String.class);
  final String[] seenCategories=new String[sentData.size()];
  for (int i=0; i < sentData.size(); i++) {
    seenCategories[i]=sentData.get(i).getFirst();
    int expectedCount=(sentData.get(i).getFirst().equals(uniqueCategories[0])) ? 8 : 4;
    assertThat(sentData.get(i).getSecond(),Matchers.allOf(everyItem(equalTo(line)),IsIterableWithSize.<String>iterableWithSize(expectedCount)));
  }
  assertThat(seenCategories,arrayContainingInAnyOrder(expectedCategories));
  ImmutableSortedSet<Path> logs=filesystem.getMtimeSortedMatchingDirectoryContents(logDir,LOGFILE_PATTERN);
  Path notRemovedLog=filesystem.resolve(logDir.resolve(LOGFILE_PREFIX + ids[0] + LOGFILE_SUFFIX));
  assertThat(logs,Matchers.allOf(hasItem(notRemovedLog),IsIterableWithSize.<Path>iterableWithSize(1)));
}

Fixed version (ground truth):
@Test public void sendStoredLogs() throws Exception {
  final ImmutableList<String> blacklistCategories=ImmutableList.of();
  final int maxScribeOfflineLogsKB=2;
  final ProjectFilesystem filesystem=new ProjectFilesystem(tmp.getRoot());
  final Path logDir=filesystem.getBuckPaths().getOfflineLogDir();
  final ObjectMapper objectMapper=ObjectMappers.newDefaultInstance();
  final String[] ids={"String_Node_Str","String_Node_Str","String_Node_Str"};
  final String[] uniqueCategories={"String_Node_Str","String_Node_Str"};
  final String[] categories={uniqueCategories[0],uniqueCategories[1],uniqueCategories[0]};
  final String testCategory="String_Node_Str";
  final String line="String_Node_Str";
  final List<Pair<String,Iterable<String>>> sentData=new ArrayList<>();
  final ScribeLogger succeeddingLogger=new ScribeLogger(){
    @Override public ListenableFuture<Void> log(    String category,    Iterable<String> lines){
      if (!category.equals(testCategory)) {
        sentData.add(new Pair<>(category,lines));
      }
      return Futures.immediateFuture(null);
    }
    @Override public void close() throws IOException {
    }
  }
;
  filesystem.mkdirs(logDir);
  for (  String id : ids) {
    File log=filesystem.resolve(logDir.resolve(LOGFILE_PREFIX + id + LOGFILE_SUFFIX)).toFile();
    BufferedOutputStream logFileStoreStream=new BufferedOutputStream(new FileOutputStream(log));
    for (    String category : categories) {
      byte[] scribeData=objectMapper.writeValueAsString(ScribeData.builder().setCategory(category).setLines(ImmutableList.of(line,line,line,line)).build()).getBytes(Charsets.UTF_8);
      logFileStoreStream.write(scribeData);
    }
    logFileStoreStream.close();
  }
  OfflineScribeLogger offlineLogger=new OfflineScribeLogger(succeeddingLogger,blacklistCategories,maxScribeOfflineLogsKB,filesystem,objectMapper,BuckEventBusFactory.newInstance(),new BuildId("String_Node_Str"));
  offlineLogger.log(testCategory,ImmutableList.of("String_Node_Str","String_Node_Str"));
  offlineLogger.close();
  assertEquals(4,sentData.size());
  final String[] expectedCategories=ObjectArrays.concat(uniqueCategories,uniqueCategories,String.class);
  final String[] seenCategories=new String[sentData.size()];
  for (int i=0; i < sentData.size(); i++) {
    seenCategories[i]=sentData.get(i).getFirst();
    int expectedCount=(sentData.get(i).getFirst().equals(uniqueCategories[0])) ? 8 : 4;
    assertThat(sentData.get(i).getSecond(),Matchers.allOf(everyItem(equalTo(line)),IsIterableWithSize.<String>iterableWithSize(expectedCount)));
  }
  assertThat(seenCategories,arrayContainingInAnyOrder(expectedCategories));
  ImmutableSortedSet<Path> logs=filesystem.getMtimeSortedMatchingDirectoryContents(logDir,LOGFILE_PATTERN);
  Path notRemovedLog=filesystem.resolve(logDir.resolve(LOGFILE_PREFIX + ids[0] + LOGFILE_SUFFIX));
  assertThat(logs,Matchers.allOf(hasItem(notRemovedLog),IsIterableWithSize.<Path>iterableWithSize(1)));
}