[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [collector/release] Remove unthrown exceptions.
commit cfd3aecaf7456432841cffe07b90ed0070429d6e
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date: Mon Aug 20 14:47:34 2018 +0200
Remove unthrown exceptions.
---
src/main/java/org/torproject/metrics/collector/Main.java | 2 +-
.../metrics/collector/bridgedescs/BridgeDescriptorParser.java | 4 +---
.../metrics/collector/bridgedescs/SanitizedBridgesWriter.java | 3 +--
.../metrics/collector/exitlists/ExitListDownloader.java | 2 +-
.../torproject/metrics/collector/indexer/CreateIndexJson.java | 3 +--
.../torproject/metrics/collector/relaydescs/ArchiveWriter.java | 2 +-
.../org/torproject/metrics/collector/webstats/LogFileMap.java | 9 +++------
.../torproject/metrics/collector/webstats/SanitizeWeblogs.java | 3 +--
src/test/java/org/torproject/metrics/collector/MainTest.java | 6 +++---
.../collector/bridgedescs/BridgeDescriptorParserTest.java | 2 +-
.../metrics/collector/bridgedescs/TarballTestBuilder.java | 2 +-
.../org/torproject/metrics/collector/conf/ConfigurationTest.java | 4 ++--
src/test/java/org/torproject/metrics/collector/cron/Broken.java | 3 +--
src/test/java/org/torproject/metrics/collector/cron/Counter.java | 3 +--
src/test/java/org/torproject/metrics/collector/cron/Dummy.java | 3 +--
.../org/torproject/metrics/collector/sync/FileCollector.java | 4 +---
.../torproject/metrics/collector/sync/SyncPersistenceTest.java | 4 ++--
.../torproject/metrics/collector/webstats/LogMetadataTest.java | 2 +-
18 files changed, 24 insertions(+), 37 deletions(-)
diff --git a/src/main/java/org/torproject/metrics/collector/Main.java b/src/main/java/org/torproject/metrics/collector/Main.java
index 6233dd2..05aead7 100644
--- a/src/main/java/org/torproject/metrics/collector/Main.java
+++ b/src/main/java/org/torproject/metrics/collector/Main.java
@@ -61,7 +61,7 @@ public class Main {
* At most one argument.
* See class description {@link Main}.
*/
- public static void main(String[] args) throws Exception {
+ public static void main(String[] args) {
try {
Path confPath = null;
if (args == null || args.length == 0) {
diff --git a/src/main/java/org/torproject/metrics/collector/bridgedescs/BridgeDescriptorParser.java b/src/main/java/org/torproject/metrics/collector/bridgedescs/BridgeDescriptorParser.java
index 5134f0f..c993d89 100644
--- a/src/main/java/org/torproject/metrics/collector/bridgedescs/BridgeDescriptorParser.java
+++ b/src/main/java/org/torproject/metrics/collector/bridgedescs/BridgeDescriptorParser.java
@@ -3,8 +3,6 @@
package org.torproject.metrics.collector.bridgedescs;
-import org.torproject.metrics.collector.conf.ConfigurationException;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -32,7 +30,7 @@ public class BridgeDescriptorParser {
/** Parses the first line of the given descriptor data to determine the
* descriptor type and passes it to the sanitized bridges writer. */
public void parse(byte[] allData, String dateTime,
- String authorityFingerprint) throws ConfigurationException {
+ String authorityFingerprint) {
try {
BufferedReader br = new BufferedReader(new StringReader(
new String(allData, "US-ASCII")));
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 6511e66..7c335c9 100644
--- a/src/main/java/org/torproject/metrics/collector/bridgedescs/SanitizedBridgesWriter.java
+++ b/src/main/java/org/torproject/metrics/collector/bridgedescs/SanitizedBridgesWriter.java
@@ -440,8 +440,7 @@ public class SanitizedBridgesWriter extends CollecTorMain {
* Sanitizes a network status and writes it to disk.
*/
public void sanitizeAndStoreNetworkStatus(byte[] data,
- String publicationTime, String authorityFingerprint)
- throws ConfigurationException {
+ String publicationTime, String authorityFingerprint) {
if (this.persistenceProblemWithSecrets) {
/* There's a persistence problem, so we shouldn't scrub more IP
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 4ef8974..2531cb7 100644
--- a/src/main/java/org/torproject/metrics/collector/exitlists/ExitListDownloader.java
+++ b/src/main/java/org/torproject/metrics/collector/exitlists/ExitListDownloader.java
@@ -194,7 +194,7 @@ public class ExitListDownloader extends CollecTorMain {
/** Delete all files from the rsync directory that have not been modified
* in the last three days. */
- public void cleanUpRsyncDirectory() throws ConfigurationException {
+ public void cleanUpRsyncDirectory() {
long cutOffMillis = System.currentTimeMillis()
- 3L * 24L * 60L * 60L * 1000L;
Stack<File> allFiles = new Stack<>();
diff --git a/src/main/java/org/torproject/metrics/collector/indexer/CreateIndexJson.java b/src/main/java/org/torproject/metrics/collector/indexer/CreateIndexJson.java
index 55ebd15..5f3a649 100644
--- a/src/main/java/org/torproject/metrics/collector/indexer/CreateIndexJson.java
+++ b/src/main/java/org/torproject/metrics/collector/indexer/CreateIndexJson.java
@@ -8,7 +8,6 @@ import org.torproject.descriptor.index.FileNode;
import org.torproject.descriptor.index.IndexNode;
import org.torproject.descriptor.internal.FileType;
import org.torproject.metrics.collector.conf.Configuration;
-import org.torproject.metrics.collector.conf.ConfigurationException;
import org.torproject.metrics.collector.conf.Key;
import org.torproject.metrics.collector.cron.CollecTorMain;
@@ -82,7 +81,7 @@ public class CreateIndexJson extends CollecTorMain {
}
@Override
- protected void startProcessing() throws ConfigurationException {
+ protected void startProcessing() {
try {
indexJsonFile = new File(config.getPath(Key.IndexPath).toFile(),
"index.json");
diff --git a/src/main/java/org/torproject/metrics/collector/relaydescs/ArchiveWriter.java b/src/main/java/org/torproject/metrics/collector/relaydescs/ArchiveWriter.java
index 31dfdef..98d2864 100644
--- a/src/main/java/org/torproject/metrics/collector/relaydescs/ArchiveWriter.java
+++ b/src/main/java/org/torproject/metrics/collector/relaydescs/ArchiveWriter.java
@@ -90,7 +90,7 @@ public class ArchiveWriter extends CollecTorMain {
private static final String MICRODESCS = "microdescs";
/** Initialize an archive writer with a given configuration. */
- public ArchiveWriter(Configuration config) throws ConfigurationException {
+ public ArchiveWriter(Configuration config) {
super(config);
this.mapPathDescriptors.put("recent/relay-descriptors/votes",
RelayNetworkStatusVote.class);
diff --git a/src/main/java/org/torproject/metrics/collector/webstats/LogFileMap.java b/src/main/java/org/torproject/metrics/collector/webstats/LogFileMap.java
index 7fa3970..b265e4b 100644
--- a/src/main/java/org/torproject/metrics/collector/webstats/LogFileMap.java
+++ b/src/main/java/org/torproject/metrics/collector/webstats/LogFileMap.java
@@ -37,8 +37,7 @@ public class LogFileMap
try {
Files.walkFileTree(startDir, new SimpleFileVisitor<Path>() {
@Override
- public FileVisitResult visitFile(Path path, BasicFileAttributes att)
- throws IOException {
+ public FileVisitResult visitFile(Path path, BasicFileAttributes att) {
Optional<LogMetadata> optionalMetadata = LogMetadata.create(path);
if (optionalMetadata.isPresent()) {
logFileMap.add(optionalMetadata.get());
@@ -47,14 +46,12 @@ public class LogFileMap
}
@Override
- public FileVisitResult visitFileFailed(Path path, IOException ex)
- throws IOException {
+ public FileVisitResult visitFileFailed(Path path, IOException ex) {
return logIfError(path, ex);
}
@Override
- public FileVisitResult postVisitDirectory(Path path, IOException ex)
- throws IOException {
+ public FileVisitResult postVisitDirectory(Path path, IOException ex) {
return logIfError(path, ex);
}
diff --git a/src/main/java/org/torproject/metrics/collector/webstats/SanitizeWeblogs.java b/src/main/java/org/torproject/metrics/collector/webstats/SanitizeWeblogs.java
index 3d25cea..32d4702 100644
--- a/src/main/java/org/torproject/metrics/collector/webstats/SanitizeWeblogs.java
+++ b/src/main/java/org/torproject/metrics/collector/webstats/SanitizeWeblogs.java
@@ -18,7 +18,6 @@ import org.torproject.descriptor.log.InternalWebServerAccessLog;
import org.torproject.descriptor.log.WebServerAccessLogImpl;
import org.torproject.descriptor.log.WebServerAccessLogLine;
import org.torproject.metrics.collector.conf.Configuration;
-import org.torproject.metrics.collector.conf.ConfigurationException;
import org.torproject.metrics.collector.conf.Key;
import org.torproject.metrics.collector.conf.SourceType;
import org.torproject.metrics.collector.cron.CollecTorMain;
@@ -86,7 +85,7 @@ public class SanitizeWeblogs extends CollecTorMain {
}
@Override
- protected void startProcessing() throws ConfigurationException {
+ protected void startProcessing() {
try {
Files.createDirectories(this.config.getPath(Key.OutputPath));
Files.createDirectories(this.config.getPath(Key.RecentPath));
diff --git a/src/test/java/org/torproject/metrics/collector/MainTest.java b/src/test/java/org/torproject/metrics/collector/MainTest.java
index 6459040..820cfb6 100644
--- a/src/test/java/org/torproject/metrics/collector/MainTest.java
+++ b/src/test/java/org/torproject/metrics/collector/MainTest.java
@@ -55,7 +55,7 @@ public class MainTest {
}
@Test()
- public void testInitializationNullArgs() throws Exception {
+ public void testInitializationNullArgs() {
File conf = new File(Main.CONF_FILE);
checkCleanEnv(conf);
Main.main(null);
@@ -77,7 +77,7 @@ public class MainTest {
}
@Test()
- public void testInitializationEmptyArgs() throws Exception {
+ public void testInitializationEmptyArgs() {
File conf = new File(Main.CONF_FILE);
checkCleanEnv(conf);
Main.main(new String[] { });
@@ -86,7 +86,7 @@ public class MainTest {
}
@Test()
- public void testInitializationTooManyArgs() throws Exception {
+ public void testInitializationTooManyArgs() {
File conf = new File(Main.CONF_FILE);
checkCleanEnv(conf);
Main.main(new String[] { "x", "y" });
diff --git a/src/test/java/org/torproject/metrics/collector/bridgedescs/BridgeDescriptorParserTest.java b/src/test/java/org/torproject/metrics/collector/bridgedescs/BridgeDescriptorParserTest.java
index 040d161..43fad5e 100644
--- a/src/test/java/org/torproject/metrics/collector/bridgedescs/BridgeDescriptorParserTest.java
+++ b/src/test/java/org/torproject/metrics/collector/bridgedescs/BridgeDescriptorParserTest.java
@@ -10,7 +10,7 @@ import org.junit.Test;
public class BridgeDescriptorParserTest {
@Test(expected = IllegalArgumentException.class)
- public void testNullArgForConstructor() throws Exception {
+ public void testNullArgForConstructor() {
new BridgeDescriptorParser(null);
}
diff --git a/src/test/java/org/torproject/metrics/collector/bridgedescs/TarballTestBuilder.java b/src/test/java/org/torproject/metrics/collector/bridgedescs/TarballTestBuilder.java
index 44f4490..e2f4c40 100644
--- a/src/test/java/org/torproject/metrics/collector/bridgedescs/TarballTestBuilder.java
+++ b/src/test/java/org/torproject/metrics/collector/bridgedescs/TarballTestBuilder.java
@@ -63,7 +63,7 @@ class TarballTestBuilder {
/** Adds a new file to the tarball with given name, last-modified time, and
* descriptor builders to generate the file content. */
TarballTestBuilder add(String fileName, long modifiedMillis,
- List<TestDescriptorBuilder> descriptorBuilders) throws IOException {
+ List<TestDescriptorBuilder> descriptorBuilders) {
TarballFile file = new TarballFile();
file.modifiedMillis = modifiedMillis;
file.descriptorBuilders = descriptorBuilders;
diff --git a/src/test/java/org/torproject/metrics/collector/conf/ConfigurationTest.java b/src/test/java/org/torproject/metrics/collector/conf/ConfigurationTest.java
index d91013b..f6172bf 100644
--- a/src/test/java/org/torproject/metrics/collector/conf/ConfigurationTest.java
+++ b/src/test/java/org/torproject/metrics/collector/conf/ConfigurationTest.java
@@ -37,14 +37,14 @@ public class ConfigurationTest {
public TemporaryFolder tmpf = new TemporaryFolder();
@Test()
- public void testKeyCount() throws Exception {
+ public void testKeyCount() {
assertEquals("The number of properties keys in enum Key changed."
+ "\n This test class should be adapted.",
53, Key.values().length);
}
@Test()
- public void testConfiguration() throws Exception {
+ public void testConfiguration() {
Configuration conf = new Configuration();
String val = "xyz";
conf.setProperty(Key.OutputPath.name(), val);
diff --git a/src/test/java/org/torproject/metrics/collector/cron/Broken.java b/src/test/java/org/torproject/metrics/collector/cron/Broken.java
index ef896bf..44aa88b 100644
--- a/src/test/java/org/torproject/metrics/collector/cron/Broken.java
+++ b/src/test/java/org/torproject/metrics/collector/cron/Broken.java
@@ -4,7 +4,6 @@
package org.torproject.metrics.collector.cron;
import org.torproject.metrics.collector.conf.Configuration;
-import org.torproject.metrics.collector.conf.ConfigurationException;
import java.util.concurrent.atomic.AtomicInteger;
@@ -17,7 +16,7 @@ public class Broken extends CollecTorMain {
}
@Override
- public void startProcessing() throws ConfigurationException {
+ public void startProcessing() {
count.getAndIncrement();
try {
Thread.sleep(10);
diff --git a/src/test/java/org/torproject/metrics/collector/cron/Counter.java b/src/test/java/org/torproject/metrics/collector/cron/Counter.java
index d48b62c..f783d7b 100644
--- a/src/test/java/org/torproject/metrics/collector/cron/Counter.java
+++ b/src/test/java/org/torproject/metrics/collector/cron/Counter.java
@@ -1,7 +1,6 @@
package org.torproject.metrics.collector.cron;
import org.torproject.metrics.collector.conf.Configuration;
-import org.torproject.metrics.collector.conf.ConfigurationException;
import java.util.concurrent.atomic.AtomicInteger;
@@ -14,7 +13,7 @@ public class Counter extends CollecTorMain {
}
@Override
- public void startProcessing() throws ConfigurationException {
+ public void startProcessing() {
count.getAndIncrement();
}
diff --git a/src/test/java/org/torproject/metrics/collector/cron/Dummy.java b/src/test/java/org/torproject/metrics/collector/cron/Dummy.java
index 1110676..c26da7d 100644
--- a/src/test/java/org/torproject/metrics/collector/cron/Dummy.java
+++ b/src/test/java/org/torproject/metrics/collector/cron/Dummy.java
@@ -1,7 +1,6 @@
package org.torproject.metrics.collector.cron;
import org.torproject.metrics.collector.conf.Configuration;
-import org.torproject.metrics.collector.conf.ConfigurationException;
public class Dummy extends CollecTorMain {
@@ -10,7 +9,7 @@ public class Dummy extends CollecTorMain {
}
@Override
- public void startProcessing() throws ConfigurationException {
+ public void startProcessing() {
// dummy doesn't do anything.
}
diff --git a/src/test/java/org/torproject/metrics/collector/sync/FileCollector.java b/src/test/java/org/torproject/metrics/collector/sync/FileCollector.java
index 57d9216..e84a62f 100644
--- a/src/test/java/org/torproject/metrics/collector/sync/FileCollector.java
+++ b/src/test/java/org/torproject/metrics/collector/sync/FileCollector.java
@@ -4,7 +4,6 @@
package org.torproject.metrics.collector.sync;
import java.io.File;
-import java.io.IOException;
import java.nio.file.FileVisitResult;
import java.nio.file.Path;
import java.nio.file.SimpleFileVisitor;
@@ -20,8 +19,7 @@ public class FileCollector extends SimpleFileVisitor<Path> {
}
@Override
- public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
- throws IOException {
+ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
this.list.add(file.toFile());
return FileVisitResult.CONTINUE;
}
diff --git a/src/test/java/org/torproject/metrics/collector/sync/SyncPersistenceTest.java b/src/test/java/org/torproject/metrics/collector/sync/SyncPersistenceTest.java
index 0a20338..101fa8b 100644
--- a/src/test/java/org/torproject/metrics/collector/sync/SyncPersistenceTest.java
+++ b/src/test/java/org/torproject/metrics/collector/sync/SyncPersistenceTest.java
@@ -355,7 +355,7 @@ public class SyncPersistenceTest {
.getClassLoader().getResource(filename).toURI())).toPath());
}
- private String stringFromResource() throws Exception {
+ private String stringFromResource() {
BufferedReader br = new BufferedReader(new InputStreamReader(getClass()
.getClassLoader().getResourceAsStream(filename)));
return br.lines().collect(Collectors.joining("\n", "", "\n"));
@@ -366,7 +366,7 @@ public class SyncPersistenceTest {
.collect(Collectors.joining("\n", "", "\n"));
}
- private List<String> linesFromResource(String filename) throws Exception {
+ private List<String> linesFromResource(String filename) {
BufferedReader br = new BufferedReader(new InputStreamReader(getClass()
.getClassLoader().getResourceAsStream(filename)));
return br.lines().collect(Collectors.toList());
diff --git a/src/test/java/org/torproject/metrics/collector/webstats/LogMetadataTest.java b/src/test/java/org/torproject/metrics/collector/webstats/LogMetadataTest.java
index 9a58cb9..24629ab 100644
--- a/src/test/java/org/torproject/metrics/collector/webstats/LogMetadataTest.java
+++ b/src/test/java/org/torproject/metrics/collector/webstats/LogMetadataTest.java
@@ -67,7 +67,7 @@ public class LogMetadataTest {
}
@Test
- public void testCreate() throws Exception {
+ public void testCreate() {
Optional<LogMetadata> element = LogMetadata.create(this.path);
assertEquals(this.failureMessage, this.valid, element.isPresent());
if (!this.valid) {
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits