commit b756eee63254cbdd72bd5aca6f9d339a7b421014 Author: Karsten Loesing karsten.loesing@gmx.net Date: Tue Aug 21 12:01:31 2018 +0200
Avoid double-initialization of a local variable.
Note that the previous code was not wrong. It declared a local variable and it read a line (containing headers). But these are two distinct things, and doing them on one line confused the code analyzer. Splitting them is just fine. --- src/main/java/org/torproject/onionoo/updater/LookupService.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/main/java/org/torproject/onionoo/updater/LookupService.java b/src/main/java/org/torproject/onionoo/updater/LookupService.java index 495fec7..44c4d84 100644 --- a/src/main/java/org/torproject/onionoo/updater/LookupService.java +++ b/src/main/java/org/torproject/onionoo/updater/LookupService.java @@ -129,7 +129,8 @@ public class LookupService { this.geoLite2CityBlocksIPv4CsvFile)) { SortedSet<Long> sortedAddressNumbers = new TreeSet<>( addressStringNumbers.values()); - String line = br.readLine(); + String line; + br.readLine(); while ((line = br.readLine()) != null) { String[] parts = line.split(",", -1); if (parts.length < 9) { @@ -187,7 +188,8 @@ public class LookupService { try (BufferedReader br = this.createBufferedReaderFromUtf8File( this.geoLite2CityLocationsEnCsvFile)) { Set<Long> blockNumbers = new HashSet<>(addressNumberBlocks.values()); - String line = br.readLine(); + String line; + br.readLine(); while ((line = br.readLine()) != null) { String[] parts = line.replaceAll(""", "").split(",", 13); if (parts.length != 13) {
tor-commits@lists.torproject.org