diff --git a/src/main/java/com/tibagni/logviewer/filter/Filter.java b/src/main/java/com/tibagni/logviewer/filter/Filter.java index e6ec1d3..d007335 100644 --- a/src/main/java/com/tibagni/logviewer/filter/Filter.java +++ b/src/main/java/com/tibagni/logviewer/filter/Filter.java @@ -19,14 +19,14 @@ public class Filter { private LogLevel verbosity = LogLevel.VERBOSE; private Pattern pattern; private int flags = Pattern.CASE_INSENSITIVE; - private ContextInfo temporaryInfo; - private boolean isSimpleFilter; - public boolean wasLoadedFromLegacyFile = false; - private Filter() { } + public boolean wasLoadedFromLegacyFile = false; + // We intentionally don't copy the temporary info as it is temporary + // We intentionally don't copy 'wasLoadedFromLegacyFile' as the copied filter would not have been loaded from a file + @SuppressWarnings("CopyConstructorMissesField") public Filter(Filter from) throws FilterException { name = from.name; color = new Color(from.color.getRGB()); @@ -35,9 +35,6 @@ public Filter(Filter from) throws FilterException { pattern = getPattern(from.pattern.pattern()); verbosity = from.verbosity; isSimpleFilter = from.isSimpleFilter; - if (temporaryInfo != null) { - temporaryInfo = new ContextInfo(from.temporaryInfo); - } } public Filter(String name, String pattern, Color color, LogLevel verbosity) throws FilterException { @@ -95,8 +92,7 @@ public static Filter createFromString(String filterString) throws FilterExceptio int flags = Integer.parseInt(params[2]); boolean isCaseSensitive = (flags & Pattern.CASE_INSENSITIVE) == 0; - Filter filter = new Filter(); - filter.updateFilter(name, pattern, color, verbosity, isCaseSensitive); + Filter filter = new Filter(name, pattern, color, verbosity, isCaseSensitive); filter.wasLoadedFromLegacyFile = isLegacy; return filter; } catch (Exception e) { @@ -216,18 +212,9 @@ public static class ContextInfo { private final Map linesFound; private Set allowedStreams; - - private ContextInfo(ContextInfo from) { - linesFound = new HashMap<>(from.linesFound); - if (from.allowedStreams != null) { - allowedStreams = new HashSet<>(from.allowedStreams); - } - } - private ContextInfo() { linesFound = new HashMap<>(); } - public void setAllowedStreams(Set allowedStreams) { this.allowedStreams = allowedStreams; } diff --git a/src/main/java/com/tibagni/logviewer/log/FileLogReader.java b/src/main/java/com/tibagni/logviewer/log/FileLogReader.java index e48da16..2e14fe7 100644 --- a/src/main/java/com/tibagni/logviewer/log/FileLogReader.java +++ b/src/main/java/com/tibagni/logviewer/log/FileLogReader.java @@ -6,6 +6,7 @@ import java.io.File; import java.io.FileReader; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; import java.util.Set; @@ -47,7 +48,7 @@ private String readFile(File file) throws IOException { String line; StringBuilder builder = new StringBuilder(); - try (BufferedReader reader = new BufferedReader(new FileReader(file))) { + try (BufferedReader reader = new BufferedReader(new FileReader(file, StandardCharsets.UTF_8))) { while ((line = reader.readLine()) != null) { builder.append(line); builder.append(StringUtils.LINE_SEPARATOR);