[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [tor-bugs] #22279 [Metrics/metrics-lib]: simplify and avoid repetition in ParserHelper methods
#22279: simplify and avoid repetition in ParserHelper methods
---------------------------------+-----------------------------------
Reporter: iwakeh | Owner: karsten
Type: enhancement | Status: needs_review
Priority: Medium | Milestone: metrics-lib 1.8.0
Component: Metrics/metrics-lib | Version:
Severity: Normal | Resolution:
Keywords: | Actual Points:
Parent ID: | Points:
Reviewer: | Sponsor:
---------------------------------+-----------------------------------
Comment (by iwakeh):
I only added a RuntimeException in a code part that according to its
comment shouldn't be reached:
{{{
--- a/src/main/java/org/torproject/descriptor/impl/ParseHelper.java
+++ b/src/main/java/org/torproject/descriptor/impl/ParseHelper.java
@@ -333,6 +333,8 @@ public class ParseHelper {
new String[]{ validatedString }, 0, 0, ",", Integer.class,
result);
} catch (DescriptorParseException e) {
- /* Should have caught in earlier validation step. */
+ throw new RuntimeException("Should have been caught in earlier
validation "
+ + "step, but wasn't. ", e);
}
return result;
}
}}}
and made the tests fail:
{{{
...
[junit] Testcase: testDirreqStatsValid took 0.009 sec
[junit] Caused an ERROR
[junit] Should have caught in earlier validation step, but wasn't.
[junit] java.lang.RuntimeException: Should have been caught in earlier
validation step, but wasn't.
[junit] at
org.torproject.descriptor.impl.ParseHelper.convertCommaSeparatedKeyIntegerValueList(ParseHelper.java:336)
[junit] at
org.torproject.descriptor.impl.ExtraInfoDescriptorImpl.getDirreqV2Ips(ExtraInfoDescriptorImpl.java:1005)
[junit] at
org.torproject.descriptor.impl.ExtraInfoDescriptorImplTest.testDirreqStatsValid(ExtraInfoDescriptorImplTest.java:1307)
[junit] Caused by: org.torproject.descriptor.DescriptorParseException:
Line '' contains an illegal key in list element ''.
[junit] at
org.torproject.descriptor.impl.ParseHelper.parseStringKeyTValueList(ParseHelper.java:436)
[junit] at
org.torproject.descriptor.impl.ParseHelper.convertCommaSeparatedKeyIntegerValueList(ParseHelper.java:332)
[junit]
...
}}}
--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/22279#comment:7>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online
_______________________________________________
tor-bugs mailing list
tor-bugs@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-bugs