@Override
  public void publish(ScannerReportWriter writer) {
    for (final DefaultInputFile inputFile : componentCache.allChangedFilesToPublish()) {
      File iofile = writer.getSourceFile(inputFile.scannerId());

      try (OutputStream output = new BufferedOutputStream(new FileOutputStream(iofile));
        InputStream in = inputFile.inputStream();
        BufferedReader reader = new BufferedReader(new InputStreamReader(in, inputFile.charset()))) {
        writeSource(reader, output, inputFile.lines());
      } catch (IOException e) {
        throw new IllegalStateException("Unable to store file source in the report", e);
      }
    }
  }
@Test
  public void publishEmptySource() throws Exception {
    FileUtils.write(sourceFile, "", StandardCharsets.ISO_8859_1);

    publisher.publish(writer);

    File out = writer.getSourceFile(inputFile.scannerId());
    assertThat(FileUtils.readFileToString(out, StandardCharsets.UTF_8)).isEmpty();
  }