Makes UTF8 BOM removal in SourceFile unconditional
Some of the callers were incorrect and was already passing true unconditionally which is the behavior introduced by this CL explicitly.
@@ -47,7 +47,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.List;
-import java.util.Objects;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
@@ -173,15 +172,10 @@ public class SourceFile implements StaticSourceFile, Serializable {
}
void setCode(String sourceCode) {
- this.setCode(sourceCode, false);
- }
-
- void setCode(String sourceCode, boolean removeUtf8Bom) {
- if (removeUtf8Bom && sourceCode != null && sourceCode.startsWith(UTF8_BOM)) {
- code = sourceCode.substring(UTF8_BOM.length());
- } else {
- code = sourceCode;
- }
+ code =
+ sourceCode != null && sourceCode.startsWith(UTF8_BOM)
+ ? sourceCode.substring(UTF8_BOM.length())
+ : sourceCode;
resetLineOffsets();
}
@@ -616,7 +610,7 @@ public class SourceFile implements StaticSourceFile, Serializable {
throw new IOException("Failed to read: " + path + ", is this input UTF-8 encoded?", e);
}
- super.setCode(cachedCode, Objects.equals(this.getCharset(), inputCharset));
+ super.setCode(cachedCode);
// Byte Order Mark can be removed by setCode
cachedCode = super.getCode();
}
@@ -724,7 +718,7 @@ public class SourceFile implements StaticSourceFile, Serializable {
// Must close the stream or else the cache won't be cleared.
inputStream.close();
- super.setCode(cachedCode, Objects.equals(this.getCharset(), StandardCharsets.UTF_8));
+ super.setCode(cachedCode);
// Byte Order Mark can be removed by setCode
cachedCode = super.getCode();
}
