Avoid running into an IOException and logging a warning for it
When we recently switched from System.err printing to slf4j logging, we started logging an IOException
that we shouldn't be running into and that we simply ignored before. This exception gets thrown when DescriptorReaderImpl
attempts to read a parse history file that doesn't exist (yet). We should simply check whether that files exists before attempting to read it. Trivial patch:
diff --git a/src/main/java/org/torproject/descriptor/impl/DescriptorReaderImpl.java b/src/main/java/org/torproject/descriptor/impl/DescriptorReaderImpl.java
index fac9475..020cdd7 100644
--- a/src/main/java/org/torproject/descriptor/impl/DescriptorReaderImpl.java
+++ b/src/main/java/org/torproject/descriptor/impl/DescriptorReaderImpl.java
@@ -200,7 +200,7 @@ public class DescriptorReaderImpl implements DescriptorReader {
}
private void readOldHistory() {
- if (this.historyFile == null) {
+ if (this.historyFile == null || !this.historyFile.exists()) {
return;
}
try {
I'd say this is a minor issue, because it prints a warning message that might confuse users, but only on the first run. No need to put out a (point) release just for this, but it would be good to fix this in master.