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

[tor-commits] [onionoo/master] Remove redundant initializers.



commit d9cafd8e6b23f3520be78768272f08b180c2920f
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date:   Mon Aug 20 16:32:12 2018 +0200

    Remove redundant initializers.
---
 src/main/java/org/torproject/onionoo/docs/ClientsHistory.java         | 4 ++--
 src/main/java/org/torproject/onionoo/docs/DocumentStore.java          | 4 ++--
 src/main/java/org/torproject/onionoo/docs/NodeStatus.java             | 2 +-
 src/main/java/org/torproject/onionoo/docs/UptimeHistory.java          | 2 +-
 .../org/torproject/onionoo/server/HttpServletResponseWrapper.java     | 2 +-
 src/main/java/org/torproject/onionoo/server/ResourceServlet.java      | 4 ++--
 .../java/org/torproject/onionoo/updater/NodeDetailsStatusUpdater.java | 2 +-
 7 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/src/main/java/org/torproject/onionoo/docs/ClientsHistory.java b/src/main/java/org/torproject/onionoo/docs/ClientsHistory.java
index 58e86e4..e4800e3 100644
--- a/src/main/java/org/torproject/onionoo/docs/ClientsHistory.java
+++ b/src/main/java/org/torproject/onionoo/docs/ClientsHistory.java
@@ -90,7 +90,7 @@ public class ClientsHistory implements Comparable<ClientsHistory> {
           + "'.  Skipping.");
       return null;
     }
-    double totalResponses = 0.0;
+    double totalResponses;
     try {
       totalResponses = Double.parseDouble(parts[4]);
     } catch (NumberFormatException e) {
@@ -125,7 +125,7 @@ public class ClientsHistory implements Comparable<ClientsHistory> {
           /* Logged by caller */
           return null;
         }
-        double value = 0.0;
+        double value;
         try {
           value = Double.parseDouble(keyValue[1]);
         } catch (NumberFormatException e) {
diff --git a/src/main/java/org/torproject/onionoo/docs/DocumentStore.java b/src/main/java/org/torproject/onionoo/docs/DocumentStore.java
index af67d91..c5444c5 100644
--- a/src/main/java/org/torproject/onionoo/docs/DocumentStore.java
+++ b/src/main/java/org/torproject/onionoo/docs/DocumentStore.java
@@ -469,7 +469,7 @@ public class DocumentStore {
           + "directory.");
       return null;
     }
-    String documentString = null;
+    String documentString;
     try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
         BufferedInputStream bis = new BufferedInputStream(
         new FileInputStream(documentFile))) {
@@ -782,7 +782,7 @@ public class DocumentStore {
     StringBuilder sb = new StringBuilder();
     for (SummaryDocument summaryDocument :
         this.cachedSummaryDocuments.values()) {
-      String line = null;
+      String line;
       try {
         line = objectMapper.writeValueAsString(summaryDocument);
       } catch (JsonProcessingException e) {
diff --git a/src/main/java/org/torproject/onionoo/docs/NodeStatus.java b/src/main/java/org/torproject/onionoo/docs/NodeStatus.java
index bef403b..fe55229 100644
--- a/src/main/java/org/torproject/onionoo/docs/NodeStatus.java
+++ b/src/main/java/org/torproject/onionoo/docs/NodeStatus.java
@@ -564,7 +564,7 @@ public class NodeStatus extends Document {
       SortedSet<String> orAddressesAndPorts = new TreeSet<>();
       SortedSet<String> exitAddresses = new TreeSet<>();
       String addresses = parts[3];
-      String address = null;
+      String address;
       if (addresses.contains(";")) {
         String[] addressParts = addresses.split(";", -1);
         if (addressParts.length != 3) {
diff --git a/src/main/java/org/torproject/onionoo/docs/UptimeHistory.java b/src/main/java/org/torproject/onionoo/docs/UptimeHistory.java
index ef73a1c..0297b37 100644
--- a/src/main/java/org/torproject/onionoo/docs/UptimeHistory.java
+++ b/src/main/java/org/torproject/onionoo/docs/UptimeHistory.java
@@ -78,7 +78,7 @@ public class UptimeHistory implements Comparable<UptimeHistory> {
           + uptimeHistoryString + "'.  Skipping.");
       return null;
     }
-    int uptimeHours = -1;
+    int uptimeHours;
     try {
       uptimeHours = Integer.parseInt(parts[2]);
     } catch (NumberFormatException e) {
diff --git a/src/main/java/org/torproject/onionoo/server/HttpServletResponseWrapper.java b/src/main/java/org/torproject/onionoo/server/HttpServletResponseWrapper.java
index f6888a4..4734e63 100644
--- a/src/main/java/org/torproject/onionoo/server/HttpServletResponseWrapper.java
+++ b/src/main/java/org/torproject/onionoo/server/HttpServletResponseWrapper.java
@@ -10,7 +10,7 @@ import javax.servlet.http.HttpServletResponse;
 
 public class HttpServletResponseWrapper {
 
-  private HttpServletResponse response = null;
+  private HttpServletResponse response;
 
   protected HttpServletResponseWrapper(HttpServletResponse response) {
     this.response = response;
diff --git a/src/main/java/org/torproject/onionoo/server/ResourceServlet.java b/src/main/java/org/torproject/onionoo/server/ResourceServlet.java
index 4257348..8f956a6 100644
--- a/src/main/java/org/torproject/onionoo/server/ResourceServlet.java
+++ b/src/main/java/org/torproject/onionoo/server/ResourceServlet.java
@@ -109,7 +109,7 @@ public class ResourceServlet extends HttpServlet {
     if (uri.startsWith("/onionoo/")) {
       uri = uri.substring("/onionoo".length());
     }
-    String resourceType = null;
+    String resourceType;
     if (uri.startsWith("/summary")) {
       resourceType = "summary";
     } else if (uri.startsWith("/details")) {
@@ -388,7 +388,7 @@ public class ResourceServlet extends HttpServlet {
     rb.setBridgesSkipped(rh.getBridgesSkipped());
     rb.setRelaysTruncated(rh.getRelaysTruncated());
     rb.setBridgesTruncated(rh.getBridgesTruncated());
-    String[] fields = null;
+    String[] fields;
     if (parameterMap.containsKey("fields")) {
       fields = this.parseFieldsParameter(parameterMap.get("fields"));
       if (fields == null) {
diff --git a/src/main/java/org/torproject/onionoo/updater/NodeDetailsStatusUpdater.java b/src/main/java/org/torproject/onionoo/updater/NodeDetailsStatusUpdater.java
index 054ccf5..7223e5a 100644
--- a/src/main/java/org/torproject/onionoo/updater/NodeDetailsStatusUpdater.java
+++ b/src/main/java/org/torproject/onionoo/updater/NodeDetailsStatusUpdater.java
@@ -458,7 +458,7 @@ public class NodeDetailsStatusUpdater implements DescriptorListener,
     for (String fingerprint : previouslyKnownNodes) {
       NodeStatus nodeStatus = this.documentStore.retrieve(
           NodeStatus.class, true, fingerprint);
-      NodeStatus updatedNodeStatus = null;
+      NodeStatus updatedNodeStatus;
       if (this.knownNodes.containsKey(fingerprint)) {
         updatedNodeStatus = this.knownNodes.get(fingerprint);
         String address = nodeStatus.getAddress();



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