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

[tor-commits] [metrics-lib/master] Remove unthrown exceptions.



commit 27b197ff04ddef0e112ccd8dfb680cb0bcf23b7e
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date:   Mon Aug 20 14:32:45 2018 +0200

    Remove unthrown exceptions.
---
 .../org/torproject/descriptor/impl/DescriptorParserImpl.java     | 3 +--
 .../java/org/torproject/descriptor/impl/RelayDirectoryImpl.java  | 3 +--
 .../org/torproject/descriptor/impl/RelayNetworkStatusImpl.java   | 6 ++----
 .../torproject/descriptor/impl/RelayNetworkStatusVoteImpl.java   | 9 +++------
 .../org/torproject/descriptor/impl/ServerDescriptorImpl.java     | 6 ++----
 .../java/org/torproject/descriptor/impl/TorperfResultImpl.java   | 3 +--
 .../torproject/descriptor/index/DescriptorIndexCollector.java    | 4 ++--
 src/test/java/org/torproject/descriptor/DescriptorTest.java      | 8 ++++----
 .../org/torproject/descriptor/impl/DescriptorParserImplTest.java | 4 ++--
 src/test/java/org/torproject/descriptor/impl/TestDescriptor.java | 3 +--
 .../descriptor/index/DescriptorIndexCollectorTest.java           | 2 +-
 .../java/org/torproject/descriptor/log/LogDescriptorTest.java    | 2 +-
 12 files changed, 21 insertions(+), 32 deletions(-)

diff --git a/src/main/java/org/torproject/descriptor/impl/DescriptorParserImpl.java b/src/main/java/org/torproject/descriptor/impl/DescriptorParserImpl.java
index ed97ef9..e8b8b08 100644
--- a/src/main/java/org/torproject/descriptor/impl/DescriptorParserImpl.java
+++ b/src/main/java/org/torproject/descriptor/impl/DescriptorParserImpl.java
@@ -140,8 +140,7 @@ public class DescriptorParserImpl implements DescriptorParser {
 
   private List<Descriptor> parseOneOrMoreDescriptors(byte[] rawDescriptorBytes,
       File sourceFile, Key key,
-      Class<? extends DescriptorImpl> descriptorClass)
-      throws DescriptorParseException {
+      Class<? extends DescriptorImpl> descriptorClass) {
     List<Descriptor> parsedDescriptors = new ArrayList<>();
     Constructor<? extends DescriptorImpl> constructor;
     try {
diff --git a/src/main/java/org/torproject/descriptor/impl/RelayDirectoryImpl.java b/src/main/java/org/torproject/descriptor/impl/RelayDirectoryImpl.java
index 802469f..d87b962 100644
--- a/src/main/java/org/torproject/descriptor/impl/RelayDirectoryImpl.java
+++ b/src/main/java/org/torproject/descriptor/impl/RelayDirectoryImpl.java
@@ -60,8 +60,7 @@ public class RelayDirectoryImpl extends DescriptorImpl
     }
   }
 
-  private void parseServerDescriptors(int offset, int length)
-      throws DescriptorParseException {
+  private void parseServerDescriptors(int offset, int length) {
     List<int[]> offsetsAndLengths = this.splitByKey(Key.ROUTER, offset, length,
         true);
     for (int[] offsetAndLength : offsetsAndLengths) {
diff --git a/src/main/java/org/torproject/descriptor/impl/RelayNetworkStatusImpl.java b/src/main/java/org/torproject/descriptor/impl/RelayNetworkStatusImpl.java
index a531395..93c66de 100644
--- a/src/main/java/org/torproject/descriptor/impl/RelayNetworkStatusImpl.java
+++ b/src/main/java/org/torproject/descriptor/impl/RelayNetworkStatusImpl.java
@@ -188,8 +188,7 @@ public class RelayNetworkStatusImpl extends NetworkStatusImpl
         parts[1]);
   }
 
-  private void parseContactLine(String line)
-      throws DescriptorParseException {
+  private void parseContactLine(String line) {
     if (line.length() > Key.CONTACT.keyword.length() + 1) {
       this.contactLine = line.substring(Key.CONTACT.keyword.length() + 1);
     } else {
@@ -222,8 +221,7 @@ public class RelayNetworkStatusImpl extends NetworkStatusImpl
         1, 2);
   }
 
-  private void parseDirOptionsLine(String[] parts)
-      throws DescriptorParseException {
+  private void parseDirOptionsLine(String[] parts) {
     String[] dirOptions = new String[parts.length - 1];
     for (int i = 1; i < parts.length; i++) {
       dirOptions[i - 1] = parts[i];
diff --git a/src/main/java/org/torproject/descriptor/impl/RelayNetworkStatusVoteImpl.java b/src/main/java/org/torproject/descriptor/impl/RelayNetworkStatusVoteImpl.java
index 3373eaa..d686fa5 100644
--- a/src/main/java/org/torproject/descriptor/impl/RelayNetworkStatusVoteImpl.java
+++ b/src/main/java/org/torproject/descriptor/impl/RelayNetworkStatusVoteImpl.java
@@ -436,8 +436,7 @@ public class RelayNetworkStatusVoteImpl extends NetworkStatusImpl
     this.orPort = ParseHelper.parsePort(line, parts[6]);
   }
 
-  private void parseContactLine(String line)
-      throws DescriptorParseException {
+  private void parseContactLine(String line) {
     if (line.length() > Key.CONTACT.keyword.length() + 1) {
       this.contactLine = line.substring(Key.CONTACT.keyword.length() + 1);
     } else {
@@ -454,8 +453,7 @@ public class RelayNetworkStatusVoteImpl extends NetworkStatusImpl
     this.sharedRandParticipate = true;
   }
 
-  private void parseSharedRandCommitLine(String line)
-      throws DescriptorParseException {
+  private void parseSharedRandCommitLine(String line) {
     if (this.sharedRandCommitLines == null) {
       this.sharedRandCommitLines = new ArrayList<>();
     }
@@ -571,8 +569,7 @@ public class RelayNetworkStatusVoteImpl extends NetworkStatusImpl
     }
   }
 
-  protected void parseFooter(int offset, int length)
-      throws DescriptorParseException {
+  protected void parseFooter(int offset, int length) {
     Scanner scanner = this.newScanner(offset, length).useDelimiter(NL);
     while (scanner.hasNext()) {
       String line = scanner.next();
diff --git a/src/main/java/org/torproject/descriptor/impl/ServerDescriptorImpl.java b/src/main/java/org/torproject/descriptor/impl/ServerDescriptorImpl.java
index 804976f..c06fb6e 100644
--- a/src/main/java/org/torproject/descriptor/impl/ServerDescriptorImpl.java
+++ b/src/main/java/org/torproject/descriptor/impl/ServerDescriptorImpl.java
@@ -286,8 +286,7 @@ public abstract class ServerDescriptorImpl extends DescriptorImpl
     }
   }
 
-  private void parsePlatformLine(String lineNoOpt)
-      throws DescriptorParseException {
+  private void parsePlatformLine(String lineNoOpt) {
     if (lineNoOpt.length() > Key.PLATFORM.keyword.length() + 1) {
       this.platform = lineNoOpt.substring(Key.PLATFORM.keyword.length() + 1);
     } else {
@@ -384,8 +383,7 @@ public abstract class ServerDescriptorImpl extends DescriptorImpl
     }
   }
 
-  private void parseContactLine(String lineNoOpt)
-      throws DescriptorParseException {
+  private void parseContactLine(String lineNoOpt) {
     if (lineNoOpt.length() > Key.CONTACT.keyword.length() + 1) {
       this.contact = lineNoOpt.substring(Key.CONTACT.keyword.length() + 1);
     } else {
diff --git a/src/main/java/org/torproject/descriptor/impl/TorperfResultImpl.java b/src/main/java/org/torproject/descriptor/impl/TorperfResultImpl.java
index 92b7750..5a8ec66 100644
--- a/src/main/java/org/torproject/descriptor/impl/TorperfResultImpl.java
+++ b/src/main/java/org/torproject/descriptor/impl/TorperfResultImpl.java
@@ -215,8 +215,7 @@ public class TorperfResultImpl extends DescriptorImpl
     }
   }
 
-  private void parseSource(String value)
-      throws DescriptorParseException {
+  private void parseSource(String value) {
     this.source = value;
   }
 
diff --git a/src/main/java/org/torproject/descriptor/index/DescriptorIndexCollector.java b/src/main/java/org/torproject/descriptor/index/DescriptorIndexCollector.java
index 873eb81..48bb40c 100644
--- a/src/main/java/org/torproject/descriptor/index/DescriptorIndexCollector.java
+++ b/src/main/java/org/torproject/descriptor/index/DescriptorIndexCollector.java
@@ -170,8 +170,8 @@ public class DescriptorIndexCollector implements DescriptorCollector {
       Files.walkFileTree(localDir.toPath(),
           new SimpleFileVisitor<Path>() {
             @Override
-            public FileVisitResult visitFile(Path path, BasicFileAttributes bfa)
-                throws IOException {
+            public FileVisitResult visitFile(Path path,
+                BasicFileAttributes bfa) {
               locals.put(path.toFile().getAbsolutePath()
                   .replace(localDir.getAbsolutePath() + "/", ""),
                       path.toFile().lastModified());
diff --git a/src/test/java/org/torproject/descriptor/DescriptorTest.java b/src/test/java/org/torproject/descriptor/DescriptorTest.java
index 2dd72e7..85ea813 100644
--- a/src/test/java/org/torproject/descriptor/DescriptorTest.java
+++ b/src/test/java/org/torproject/descriptor/DescriptorTest.java
@@ -107,7 +107,7 @@ public class DescriptorTest {
   }
 
   @Test
-  public void testCounts() throws Exception {
+  public void testCounts() {
     int descCount = 0;
     while (descs.hasNext()) {
       Descriptor desc = descs.next();
@@ -119,7 +119,7 @@ public class DescriptorTest {
   }
 
   @Test
-  public void testNewline() throws Exception {
+  public void testNewline() {
     while (descs.hasNext()) {
       Descriptor desc = descs.next();
       byte[] raw = desc.getRawDescriptorBytes();
@@ -128,7 +128,7 @@ public class DescriptorTest {
   }
 
   @Test
-  public void testTypes() throws Exception {
+  public void testTypes() {
     while (descs.hasNext()) {
       Descriptor desc = descs.next();
       assertTrue(filename + ": Expected " + descClass.getName()
@@ -139,7 +139,7 @@ public class DescriptorTest {
   }
 
   @Test
-  public void testAnnotations() throws Exception {
+  public void testAnnotations() {
     while (descs.hasNext()) {
       Descriptor desc = descs.next();
       for (String anno : annos) {
diff --git a/src/test/java/org/torproject/descriptor/impl/DescriptorParserImplTest.java b/src/test/java/org/torproject/descriptor/impl/DescriptorParserImplTest.java
index 70594d8..00b99a4 100644
--- a/src/test/java/org/torproject/descriptor/impl/DescriptorParserImplTest.java
+++ b/src/test/java/org/torproject/descriptor/impl/DescriptorParserImplTest.java
@@ -24,7 +24,7 @@ public class DescriptorParserImplTest {
   @Rule
   public ExpectedException thrown = ExpectedException.none();
 
-  private TestDescriptor makeTestDesc(byte[] bytes) throws Exception {
+  private TestDescriptor makeTestDesc(byte[] bytes) {
     return new TestDescriptor(bytes, new int[]{0, bytes.length});
   }
 
@@ -40,7 +40,7 @@ public class DescriptorParserImplTest {
       + "id ed25519 ihsbrlWToq8b01rvfszqqTMUl2ulyPV3TniKuTENCzY\n";
 
   @Test
-  public void testAnnotation() throws Exception {
+  public void testAnnotation() {
     TestDescriptor des = makeTestDesc(MICRO.getBytes());
     DescriptorParserImpl dpi = new DescriptorParserImpl();
     int parsedDescriptors = 0;
diff --git a/src/test/java/org/torproject/descriptor/impl/TestDescriptor.java b/src/test/java/org/torproject/descriptor/impl/TestDescriptor.java
index 1309070..9748f00 100644
--- a/src/test/java/org/torproject/descriptor/impl/TestDescriptor.java
+++ b/src/test/java/org/torproject/descriptor/impl/TestDescriptor.java
@@ -13,8 +13,7 @@ public class TestDescriptor extends DescriptorImpl {
     super(rawDescriptorBytes, offsetAndLength, null, blankLinesAllowed);
   }
 
-  protected TestDescriptor(byte[] rawDescriptorBytes, int[] offsetAndLength)
-      throws DescriptorParseException {
+  protected TestDescriptor(byte[] rawDescriptorBytes, int[] offsetAndLength) {
     super(rawDescriptorBytes, offsetAndLength, null);
   }
 }
diff --git a/src/test/java/org/torproject/descriptor/index/DescriptorIndexCollectorTest.java b/src/test/java/org/torproject/descriptor/index/DescriptorIndexCollectorTest.java
index bde64d6..6e4978b 100644
--- a/src/test/java/org/torproject/descriptor/index/DescriptorIndexCollectorTest.java
+++ b/src/test/java/org/torproject/descriptor/index/DescriptorIndexCollectorTest.java
@@ -276,7 +276,7 @@ public class DescriptorIndexCollectorTest {
   }
 
   @Test(expected = IllegalArgumentException.class)
-  public void testNullDirectory() throws IOException {
+  public void testNullDirectory() {
     new DescriptorIndexCollector().collectDescriptors(
         null, new String[]{}, 100L, null, false);
   }
diff --git a/src/test/java/org/torproject/descriptor/log/LogDescriptorTest.java b/src/test/java/org/torproject/descriptor/log/LogDescriptorTest.java
index e76566a..2e13a52 100644
--- a/src/test/java/org/torproject/descriptor/log/LogDescriptorTest.java
+++ b/src/test/java/org/torproject/descriptor/log/LogDescriptorTest.java
@@ -142,7 +142,7 @@ public class LogDescriptorTest {
   }
 
   @Test
-  public void testUnknownLogType() throws Exception {
+  public void testUnknownLogType() {
     assertEquals(dataUsed(), 1, this.reader.getParsedFiles().size());
     File logFile = new File(this.reader.getParsedFiles().firstKey());
     DescriptorParser dp = DescriptorSourceFactory.createDescriptorParser();



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