allow preserveAbsolutePath to be final
private String name = "";
/** Whether to enforce leading slashes on the name */
- private boolean preserveAbsolutePath;
+ private final boolean preserveAbsolutePath;
/** The entry's permission mode. */
private int mode;
/**
* Construct an empty entry and prepares the header values.
*/
- private TarArchiveEntry() {
+ private TarArchiveEntry(boolean preserveAbsolutePath) {
String user = System.getProperty("user.name", "");
if (user.length() > MAX_NAMELEN) {
@@ -236,6 +236,7 @@ private TarArchiveEntry() {
this.userName = user;
this.file = null;
+ this.preserveAbsolutePath = preserveAbsolutePath;
}
/**
@@ -268,9 +269,7 @@ public TarArchiveEntry(final String name) {
* @since 1.1
*/
public TarArchiveEntry(String name, final boolean preserveAbsolutePath) {
- this();
-
- this.preserveAbsolutePath = preserveAbsolutePath;
+ this(preserveAbsolutePath);
name = normalizeFileName(name, preserveAbsolutePath);
final boolean isDir = name.endsWith("/");
@@ -373,6 +372,7 @@ public TarArchiveEntry(final File file, final String fileName) {
this.modTime = file.lastModified() / MILLIS_PER_SECOND;
this.userName = "";
+ preserveAbsolutePath = false;
}
/**
@@ -383,7 +383,7 @@ public TarArchiveEntry(final File file, final String fileName) {
* @throws IllegalArgumentException if any of the numeric fields have an invalid format
*/
public TarArchiveEntry(final byte[] headerBuf) {
- this();
+ this(false);
parseTarHeader(headerBuf);
}
@@ -399,7 +399,7 @@ public TarArchiveEntry(final byte[] headerBuf) {
*/
public TarArchiveEntry(final byte[] headerBuf, final ZipEncoding encoding)
throws IOException {
- this();
+ this(false);
parseTarHeader(headerBuf, encoding);
}
