Repository: GoogleContainerTools/jib
File: jib-core/src/main/java/com/google/cloud/tools/jib/tar/TarStreamBuilder.java (Java)

Code before:
    }
  }

  /**
   * Adds a {@link TarArchiveEntry} to the archive.
   *
   * @param entry the {@link TarArchiveEntry}
   */
  public void addTarArchiveEntry(TarArchiveEntry entry) {
    archiveMap.put(
        entry, entry.isFile() ? Blobs.from(entry.getPath()) : Blobs.from(ignored -> {}, true));
  }

  /**
   * Adds a blob to the archive. Note that this should be used with raw bytes and not file contents;
   * for adding files to the archive, use {@link #addTarArchiveEntry}.
   *
   * @param contents the bytes to add to the tarball
   * @param name the name of the entry (i.e. filename)
   * @param modificationTime the modification time of the entry
   */
  public void addByteEntry(byte[] contents, String name, Instant modificationTime) {
    TarArchiveEntry entry = new TarArchiveEntry(name);
    entry.setSize(contents.length);
    entry.setModTime(modificationTime.toEpochMilli());
    archiveMap.put(entry, Blobs.from(outputStream -> outputStream.write(contents), false));
  }

  /**
   * Adds a blob to the archive. Note that this should be used with non-file {@link Blob}s; for
   * adding files to the archive, use {@link #addTarArchiveEntry}.
   *
   * @param blob the {@link Blob} to add to the tarball
   * @param size the size (in bytes) of {@code blob}
   * @param name the name of the entry (i.e. filename)
   * @param modificationTime the modification time of the entry
   */
  public void addBlobEntry(Blob blob, long size, String name, Instant modificationTime) {
    TarArchiveEntry entry = new TarArchiveEntry(name);
    entry.setSize(size);
    entry.setModTime(modificationTime.toEpochMilli());
    archiveMap.put(entry, blob);
  }
}


Review comment (suggestion):
I think true. (`contents` isn't totally immutable as it's a reference to an array, but this is implied and assumed in the existing code.)
```suggestion
    archiveMap.put(entry, Blobs.from(outputStream -> outputStream.write(contents), true));
```

Code after:
    }
  }

  /**
   * Adds a {@link TarArchiveEntry} to the archive.
   *
   * @param entry the {@link TarArchiveEntry}
   */
  public void addTarArchiveEntry(TarArchiveEntry entry) {
    archiveMap.put(
        entry, entry.isFile() ? Blobs.from(entry.getPath()) : Blobs.from(ignored -> {}, true));
  }

  /**
   * Adds a blob to the archive. Note that this should be used with raw bytes and not file contents;
   * for adding files to the archive, use {@link #addTarArchiveEntry}.
   *
   * @param contents the bytes to add to the tarball
   * @param name the name of the entry (i.e. filename)
   * @param modificationTime the modification time of the entry
   */
  public void addByteEntry(byte[] contents, String name, Instant modificationTime) {
    TarArchiveEntry entry = new TarArchiveEntry(name);
    entry.setSize(contents.length);
    entry.setModTime(modificationTime.toEpochMilli());
    archiveMap.put(entry, Blobs.from(outputStream -> outputStream.write(contents), true));
  }

  /**
   * Adds a blob to the archive. Note that this should be used with non-file {@link Blob}s; for
   * adding files to the archive, use {@link #addTarArchiveEntry}.
   *
   * @param blob the {@link Blob} to add to the tarball
   * @param size the size (in bytes) of {@code blob}
   * @param name the name of the entry (i.e. filename)
   * @param modificationTime the modification time of the entry
   */
  public void addBlobEntry(Blob blob, long size, String name, Instant modificationTime) {
    TarArchiveEntry entry = new TarArchiveEntry(name);
    entry.setSize(size);
    entry.setModTime(modificationTime.toEpochMilli());
    archiveMap.put(entry, blob);
  }
}