[metrics-bugs] #22681 [Metrics/Onionoo]: adapt onionoo to use metrics-lib 1.9.0
Tor Bug Tracker & Wiki
blackhole at torproject.org
Thu Jun 29 09:42:22 UTC 2017
#22681: adapt onionoo to use metrics-lib 1.9.0
-----------------------------+------------------------------
Reporter: iwakeh | Owner: metrics-team
Type: enhancement | Status: needs_review
Priority: Medium | Milestone:
Component: Metrics/Onionoo | Version:
Severity: Normal | Resolution:
Keywords: | Actual Points:
Parent ID: | Points:
Reviewer: | Sponsor:
-----------------------------+------------------------------
Comment (by iwakeh):
Tests and checks pass with 1.9.0 and 2.0.0.
I'd like to have more explicit code
[https://gitweb.torproject.org/user/karsten/onionoo.git/tree/src/main/java/org/torproject/onionoo/updater/DescriptorQueue.java?h=task-22681&id=ccd5a7e58ca459ef3ed5ce168e815efedb147e0b#n146
here], where a null value signals the end of the loop sort of indirectly.
Knowing that this also is a matter of taste a first suggestion for more
obvious code:
{{{
diff --git
a/src/main/java/org/torproject/onionoo/updater/DescriptorQueue.java
b/src/main/java/org/torproject/onionoo/updater/DescriptorQueue.java
index ae68b41..9e49840 100644
--- a/src/main/java/org/torproject/onionoo/updater/DescriptorQueue.java
+++ b/src/main/java/org/torproject/onionoo/updater/DescriptorQueue.java
@@ -129,6 +129,7 @@ class DescriptorQueue {
}
}
+ /** Returns the next parseable Descriptor. */
public Descriptor nextDescriptor() {
Descriptor nextDescriptor = null;
if (null == this.descriptors) {
@@ -143,14 +144,13 @@ class DescriptorQueue {
return null;
}
}
- while (null == nextDescriptor && this.descriptors.hasNext()) {
+ while (this.descriptors.hasNext()) {
nextDescriptor = this.descriptors.next();
- if (nextDescriptor instanceof UnparseableDescriptor) {
- nextDescriptor = null;
- continue;
+ if (!(nextDescriptor instanceof UnparseableDescriptor)) {
+ this.returnedDescriptors++;
+ this.returnedBytes += nextDescriptor.getRawDescriptorLength();
+ break;
}
- this.returnedDescriptors++;
- this.returnedBytes += nextDescriptor.getRawDescriptorLength();
}
return nextDescriptor;
}
}}}
All in all merge ready after a change regarding the above topic.
Again, the changes are not at all covered by test, i.e., more intensive
pre-deployment-testing is necessary (new ticket).
--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/22681#comment:7>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online
More information about the metrics-bugs
mailing list