[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [metrics-lib/master] Remove redundant initializers.



commit 9cb9b78d945a78c90d12a3874c50f69bba7736b6
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date:   Mon Aug 20 16:29:47 2018 +0200

    Remove redundant initializers.
---
 .../java/org/torproject/descriptor/impl/DescriptorReaderImpl.java     | 2 +-
 src/main/java/org/torproject/descriptor/impl/Key.java                 | 2 +-
 .../java/org/torproject/descriptor/impl/NetworkStatusEntryImpl.java   | 2 +-
 src/main/java/org/torproject/descriptor/impl/NetworkStatusImpl.java   | 2 +-
 src/main/java/org/torproject/descriptor/impl/ParseHelper.java         | 2 +-
 src/main/java/org/torproject/descriptor/impl/TorperfResultImpl.java   | 2 +-
 .../org/torproject/descriptor/index/DescriptorIndexCollector.java     | 4 ++--
 src/main/java/org/torproject/descriptor/internal/FileType.java        | 2 +-
 8 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/main/java/org/torproject/descriptor/impl/DescriptorReaderImpl.java b/src/main/java/org/torproject/descriptor/impl/DescriptorReaderImpl.java
index a8a7790..8b0c64c 100644
--- a/src/main/java/org/torproject/descriptor/impl/DescriptorReaderImpl.java
+++ b/src/main/java/org/torproject/descriptor/impl/DescriptorReaderImpl.java
@@ -178,7 +178,7 @@ public class DescriptorReaderImpl implements DescriptorReader {
       if (historyFile == null || !historyFile.exists()) {
         return;
       }
-      List<String> lines = null;
+      List<String> lines;
       try {
         lines = Files.readAllLines(historyFile.toPath(),
             StandardCharsets.UTF_8);
diff --git a/src/main/java/org/torproject/descriptor/impl/Key.java b/src/main/java/org/torproject/descriptor/impl/Key.java
index 763ecbf..602df09 100644
--- a/src/main/java/org/torproject/descriptor/impl/Key.java
+++ b/src/main/java/org/torproject/descriptor/impl/Key.java
@@ -163,7 +163,7 @@ public enum Key {
   /** Retrieve a Key for a keyword.
    *  Returns Key.INVALID for non-existing keywords. */
   public static Key get(String keyword) {
-    Key res = INVALID;
+    Key res;
     try {
       res = keywordMap.get(keyword);
     } catch (Throwable th) {
diff --git a/src/main/java/org/torproject/descriptor/impl/NetworkStatusEntryImpl.java b/src/main/java/org/torproject/descriptor/impl/NetworkStatusEntryImpl.java
index 3c0c1af..9ebedbd 100644
--- a/src/main/java/org/torproject/descriptor/impl/NetworkStatusEntryImpl.java
+++ b/src/main/java/org/torproject/descriptor/impl/NetworkStatusEntryImpl.java
@@ -77,7 +77,7 @@ public class NetworkStatusEntryImpl implements NetworkStatusEntry {
      * this.parent.length as bounds, which is not what we want! */
     Scanner scanner = this.parent.newScanner(this.offset, this.length)
         .useDelimiter(NL);
-    String line = null;
+    String line;
     if (!scanner.hasNext() || !(line = scanner.next()).startsWith("r ")) {
       throw new DescriptorParseException("Status entry must start with "
           + "an r line.");
diff --git a/src/main/java/org/torproject/descriptor/impl/NetworkStatusImpl.java b/src/main/java/org/torproject/descriptor/impl/NetworkStatusImpl.java
index 60a9ff3..0694aff 100644
--- a/src/main/java/org/torproject/descriptor/impl/NetworkStatusImpl.java
+++ b/src/main/java/org/torproject/descriptor/impl/NetworkStatusImpl.java
@@ -116,7 +116,7 @@ public abstract class NetworkStatusImpl extends DescriptorImpl {
 
   protected String[] parseClientOrServerVersions(String line,
       String[] parts) throws DescriptorParseException {
-    String[] result = null;
+    String[] result;
     switch (parts.length) {
       case 1:
         result = new String[0];
diff --git a/src/main/java/org/torproject/descriptor/impl/ParseHelper.java b/src/main/java/org/torproject/descriptor/impl/ParseHelper.java
index 93ad610..1bba92e 100644
--- a/src/main/java/org/torproject/descriptor/impl/ParseHelper.java
+++ b/src/main/java/org/torproject/descriptor/impl/ParseHelper.java
@@ -77,7 +77,7 @@ public class ParseHelper {
 
   protected static int parsePort(String line, String portString)
       throws DescriptorParseException {
-    int port = -1;
+    int port;
     try {
       port = Integer.parseInt(portString);
     } catch (NumberFormatException e) {
diff --git a/src/main/java/org/torproject/descriptor/impl/TorperfResultImpl.java b/src/main/java/org/torproject/descriptor/impl/TorperfResultImpl.java
index 5a8ec66..47de53f 100644
--- a/src/main/java/org/torproject/descriptor/impl/TorperfResultImpl.java
+++ b/src/main/java/org/torproject/descriptor/impl/TorperfResultImpl.java
@@ -300,7 +300,7 @@ public class TorperfResultImpl extends DescriptorImpl
       String line) throws DescriptorParseException {
     String key = keyValue.substring(0, keyValue.indexOf("="));
     String percentileString = key.substring("DATAPERC".length());
-    int percentile = -1;
+    int percentile;
     try {
       percentile = Integer.parseInt(percentileString);
     } catch (NumberFormatException e) {
diff --git a/src/main/java/org/torproject/descriptor/index/DescriptorIndexCollector.java b/src/main/java/org/torproject/descriptor/index/DescriptorIndexCollector.java
index 48bb40c..774708f 100644
--- a/src/main/java/org/torproject/descriptor/index/DescriptorIndexCollector.java
+++ b/src/main/java/org/torproject/descriptor/index/DescriptorIndexCollector.java
@@ -62,8 +62,8 @@ public class DescriptorIndexCollector implements DescriptorCollector {
     }
     log.info("Indexing local directory {}.", localDirectory.getAbsolutePath());
     SortedMap<String, Long> localFiles = statLocalDirectory(localDirectory);
-    SortedMap<String, FileNode> remoteFiles = null;
-    IndexNode index = null;
+    SortedMap<String, FileNode> remoteFiles;
+    IndexNode index;
     String indexUrlString = "";
     try {
       URL indexUrl = new URL(collecTorIndexUrlString);
diff --git a/src/main/java/org/torproject/descriptor/internal/FileType.java b/src/main/java/org/torproject/descriptor/internal/FileType.java
index 2c07df6..95acf2f 100644
--- a/src/main/java/org/torproject/descriptor/internal/FileType.java
+++ b/src/main/java/org/torproject/descriptor/internal/FileType.java
@@ -49,7 +49,7 @@ public enum FileType {
    * @since 2.1.0
    */
   public static FileType findType(String ext) {
-    FileType res = null;
+    FileType res;
     try {
       res = FileType.valueOf(ext.toUpperCase());
       return res;



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits