[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [collector/release] Remove redundant initializers.
commit cc692b7e2f26766eb977641586bd62b3c30e9767
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date: Mon Aug 20 16:29:32 2018 +0200
Remove redundant initializers.
---
src/main/java/org/torproject/metrics/collector/Main.java | 2 +-
.../metrics/collector/bridgedescs/BridgeSnapshotReader.java | 10 +++++-----
.../metrics/collector/bridgedescs/SanitizedBridgesWriter.java | 10 +++++-----
.../metrics/collector/exitlists/ExitListDownloader.java | 2 +-
.../metrics/collector/onionperf/OnionPerfDownloader.java | 4 ++--
.../torproject/metrics/collector/relaydescs/ArchiveReader.java | 8 ++++----
.../collector/relaydescs/CachedRelayDescriptorReader.java | 6 +++---
.../collector/relaydescs/RelayDescriptorDownloader.java | 6 +++---
8 files changed, 24 insertions(+), 24 deletions(-)
diff --git a/src/main/java/org/torproject/metrics/collector/Main.java b/src/main/java/org/torproject/metrics/collector/Main.java
index 05aead7..1e186d4 100644
--- a/src/main/java/org/torproject/metrics/collector/Main.java
+++ b/src/main/java/org/torproject/metrics/collector/Main.java
@@ -63,7 +63,7 @@ public class Main {
*/
public static void main(String[] args) {
try {
- Path confPath = null;
+ Path confPath;
if (args == null || args.length == 0) {
confPath = Paths.get(CONF_FILE);
} else if (args.length == 1) {
diff --git a/src/main/java/org/torproject/metrics/collector/bridgedescs/BridgeSnapshotReader.java b/src/main/java/org/torproject/metrics/collector/bridgedescs/BridgeSnapshotReader.java
index 9df94d9..abd30ab 100644
--- a/src/main/java/org/torproject/metrics/collector/bridgedescs/BridgeSnapshotReader.java
+++ b/src/main/java/org/torproject/metrics/collector/bridgedescs/BridgeSnapshotReader.java
@@ -55,7 +55,7 @@ public class BridgeSnapshotReader {
logger.debug("Reading file " + pbdFile.getAbsolutePath() + "...");
try {
BufferedReader br = new BufferedReader(new FileReader(pbdFile));
- String line = null;
+ String line;
while ((line = br.readLine()) != null) {
parsed.add(line);
}
@@ -88,7 +88,7 @@ public class BridgeSnapshotReader {
try {
FileInputStream in = new FileInputStream(pop);
if (in.available() > 0) {
- TarArchiveInputStream tais = null;
+ TarArchiveInputStream tais;
if (pop.getName().endsWith(".tar.gz")) {
GzipCompressorInputStream gcis =
new GzipCompressorInputStream(in);
@@ -149,7 +149,7 @@ public class BridgeSnapshotReader {
String ascii = new String(allData, "US-ASCII");
BufferedReader br3 = new BufferedReader(new StringReader(
ascii));
- String firstLine = null;
+ String firstLine;
while ((firstLine = br3.readLine()) != null) {
if (firstLine.startsWith("@")) {
continue;
@@ -171,8 +171,8 @@ public class BridgeSnapshotReader {
skippedFiles++;
continue;
} else {
- int start = -1;
- int sig = -1;
+ int start;
+ int sig;
int end = -1;
String startToken = firstLine.startsWith("router ")
? "router " : "extra-info ";
diff --git a/src/main/java/org/torproject/metrics/collector/bridgedescs/SanitizedBridgesWriter.java b/src/main/java/org/torproject/metrics/collector/bridgedescs/SanitizedBridgesWriter.java
index 7c335c9..2bd85ef 100644
--- a/src/main/java/org/torproject/metrics/collector/bridgedescs/SanitizedBridgesWriter.java
+++ b/src/main/java/org/torproject/metrics/collector/bridgedescs/SanitizedBridgesWriter.java
@@ -242,7 +242,7 @@ public class SanitizedBridgesWriter extends CollecTorMain {
String addressPart = orAddress.substring(0,
orAddress.lastIndexOf(":"));
String portPart = orAddress.substring(orAddress.lastIndexOf(":") + 1);
- String scrubbedAddressPart = null;
+ String scrubbedAddressPart;
if (addressPart.startsWith("[")) {
scrubbedAddressPart = this.scrubIpv6Address(addressPart,
fingerprintBytes, published);
@@ -340,7 +340,7 @@ public class SanitizedBridgesWriter extends CollecTorMain {
}
hex.append(hexParts.get(1));
}
- byte[] ipBytes = null;
+ byte[] ipBytes;
try {
ipBytes = Hex.decodeHex(hex.toString().toCharArray());
} catch (DecoderException e) {
@@ -473,7 +473,7 @@ public class SanitizedBridgesWriter extends CollecTorMain {
DescriptorBuilder scrubbed = new DescriptorBuilder();
BufferedReader br = new BufferedReader(new StringReader(new String(
data, "US-ASCII")));
- String line = null;
+ String line;
String mostRecentDescPublished = null;
byte[] fingerprintBytes = null;
String descPublicationTime = null;
@@ -1120,9 +1120,9 @@ public class SanitizedBridgesWriter extends CollecTorMain {
try {
BufferedReader br = new BufferedReader(new StringReader(new String(
data, "US-ASCII")));
- String line = null;
+ String line;
DescriptorBuilder scrubbed = null;
- String hashedBridgeIdentity = null;
+ String hashedBridgeIdentity;
String masterKeyEd25519 = null;
while ((line = br.readLine()) != null) {
diff --git a/src/main/java/org/torproject/metrics/collector/exitlists/ExitListDownloader.java b/src/main/java/org/torproject/metrics/collector/exitlists/ExitListDownloader.java
index a346d02..0b7dfad 100644
--- a/src/main/java/org/torproject/metrics/collector/exitlists/ExitListDownloader.java
+++ b/src/main/java/org/torproject/metrics/collector/exitlists/ExitListDownloader.java
@@ -70,7 +70,7 @@ public class ExitListDownloader extends CollecTorMain {
recentPathName = Paths.get(config.getPath(Key.RecentPath).toString(),
EXITLISTS).toString();
Date downloadedDate = new Date();
- String downloadedExitList = null;
+ String downloadedExitList;
logger.debug("Downloading exit list...");
StringBuilder sb = new StringBuilder();
sb.append(Annotation.ExitList.toString());
diff --git a/src/main/java/org/torproject/metrics/collector/onionperf/OnionPerfDownloader.java b/src/main/java/org/torproject/metrics/collector/onionperf/OnionPerfDownloader.java
index ab7c4f9..f97a4f8 100644
--- a/src/main/java/org/torproject/metrics/collector/onionperf/OnionPerfDownloader.java
+++ b/src/main/java/org/torproject/metrics/collector/onionperf/OnionPerfDownloader.java
@@ -184,8 +184,8 @@ public class OnionPerfDownloader extends CollecTorMain {
tpfFileName);
return;
}
- int fileSize = 0;
- String date = null;
+ int fileSize;
+ String date;
try {
fileSize = Integer.parseInt(
tpfFileNameParts[tpfFileNameParts.length - 4]);
diff --git a/src/main/java/org/torproject/metrics/collector/relaydescs/ArchiveReader.java b/src/main/java/org/torproject/metrics/collector/relaydescs/ArchiveReader.java
index aea169f..74700f7 100644
--- a/src/main/java/org/torproject/metrics/collector/relaydescs/ArchiveReader.java
+++ b/src/main/java/org/torproject/metrics/collector/relaydescs/ArchiveReader.java
@@ -67,7 +67,7 @@ public class ArchiveReader {
try {
BufferedReader br = new BufferedReader(new FileReader(
archivesImportHistoryFile));
- String line = null;
+ String line;
while ((line = br.readLine()) != null) {
archivesImportHistory.add(line);
}
@@ -90,7 +90,7 @@ public class ArchiveReader {
Collections.addAll(filesInInputDir, pop.listFiles());
} else {
try {
- BufferedInputStream bis = null;
+ BufferedInputStream bis;
if (keepImportHistory
&& archivesImportHistory.contains(pop.getName())) {
ignoredFiles++;
@@ -140,7 +140,7 @@ public class ArchiveReader {
* microdescriptor. However, this breaks functional abstraction
* pretty badly. */
try {
- BufferedInputStream bis = null;
+ BufferedInputStream bis;
if (pop.getName().endsWith(".bz2")) {
FileInputStream fis = new FileInputStream(pop);
BZip2CompressorInputStream bcis =
@@ -178,7 +178,7 @@ public class ArchiveReader {
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
parseFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
String ascii = new String(allData, StandardCharsets.US_ASCII);
- int start = -1;
+ int start;
int end = -1;
String startToken = "onion-key\n";
while (end < ascii.length()) {
diff --git a/src/main/java/org/torproject/metrics/collector/relaydescs/CachedRelayDescriptorReader.java b/src/main/java/org/torproject/metrics/collector/relaydescs/CachedRelayDescriptorReader.java
index ad0f6a5..f64d019 100644
--- a/src/main/java/org/torproject/metrics/collector/relaydescs/CachedRelayDescriptorReader.java
+++ b/src/main/java/org/torproject/metrics/collector/relaydescs/CachedRelayDescriptorReader.java
@@ -110,7 +110,7 @@ public class CachedRelayDescriptorReader {
/* Check if directory information is stale. */
BufferedReader br = new BufferedReader(new StringReader(
new String(allData, "US-ASCII")));
- String line = null;
+ String line;
while ((line = br.readLine()) != null) {
if (line.startsWith("valid-after ")) {
dumpStats.append("\n").append(f.getName()).append(": ")
@@ -178,8 +178,8 @@ public class CachedRelayDescriptorReader {
} else if (f.getName().startsWith("cached-descriptors")
|| f.getName().startsWith("cached-extrainfo")) {
String ascii = new String(allData, "US-ASCII");
- int start = -1;
- int sig = -1;
+ int start;
+ int sig;
int end = -1;
String startToken =
f.getName().startsWith("cached-descriptors")
diff --git a/src/main/java/org/torproject/metrics/collector/relaydescs/RelayDescriptorDownloader.java b/src/main/java/org/torproject/metrics/collector/relaydescs/RelayDescriptorDownloader.java
index 8becbe1..f876319 100644
--- a/src/main/java/org/torproject/metrics/collector/relaydescs/RelayDescriptorDownloader.java
+++ b/src/main/java/org/torproject/metrics/collector/relaydescs/RelayDescriptorDownloader.java
@@ -898,8 +898,8 @@ public class RelayDescriptorDownloader {
this.currentTimestamp);
}
String ascii = new String(allData, StandardCharsets.US_ASCII);
- int start = -1;
- int sig = -1;
+ int start;
+ int sig;
int end = -1;
String startToken = resource.startsWith("/tor/server/")
? "router " : "extra-info ";
@@ -935,7 +935,7 @@ public class RelayDescriptorDownloader {
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
parseFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
String ascii = new String(allData, StandardCharsets.US_ASCII);
- int start = -1;
+ int start;
int end = -1;
String startToken = "onion-key\n";
while (end < ascii.length()) {
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits