Remove incorrect error-level logging
TimeZoneFinder logs when it can't find a file in the
createInstanceWithFallback(). The lack of a file is expected
(hence "fallback") so logging at error is unnecessarily
alarmist. The logging has been removed unless no files
can be found.
Bug: 63208076
Test: make
Change-Id: I49671247cb670ad814870f1ef89014975ba7d777
diff --git a/luni/src/main/java/libcore/util/TimeZoneFinder.java b/luni/src/main/java/libcore/util/TimeZoneFinder.java
index 3c68a37..37e3b4a 100644
--- a/luni/src/main/java/libcore/util/TimeZoneFinder.java
+++ b/luni/src/main/java/libcore/util/TimeZoneFinder.java
@@ -80,6 +80,7 @@
// VisibleForTesting
public static TimeZoneFinder createInstanceWithFallback(String... tzLookupFilePaths) {
+ IOException lastException = null;
for (String tzLookupFilePath : tzLookupFilePaths) {
try {
// We assume that any file in /data was validated before install, and the system
@@ -87,12 +88,18 @@
// validation cost here.
return createInstance(tzLookupFilePath);
} catch (IOException e) {
- System.logE("Unable to process file: " + tzLookupFilePath + " Trying next one.", e);
+ // There's expected to be two files, and it's normal for the first file not to
+ // exist so we don't log, but keep the lastException so we can log it if there
+ // are no valid files available.
+ if (lastException != null) {
+ e.addSuppressed(lastException);
+ }
+ lastException = e;
}
}
System.logE("No valid file found in set: " + Arrays.toString(tzLookupFilePaths)
- + " Falling back to empty map.");
+ + " Printing exceptions and falling back to empty map.", lastException);
return createInstanceForTests("<timezones><countryzones /></timezones>");
}