Class#newInstance is deprecated in Java 9 and higher, which doesn't
affect us yet in Java 8. But the suggested replacement already works
in Java 8, so that we can safely switch to that.
This is required for processing index.json files produced by CollecTor
1.13.0 or higher. We don't need those newly added fields or any other
fields added in the future. But we must not fail when fields are
added.
The bug was that we accessed static class members, namely the two maps
NetworkStatusEntryImpl#flagIndexes and #flagStrings, during instance
creation without synchronization. This worked just fine with a single
thread creating instances, but it breaks with multiple threads doing
that at the same time.
The fix is to keep a separate map per NetworkStatusImpl instance and
share that between all its NetworkStatusEntryImpl instances. This
doesn't save as much memory as sharing maps between all
NetworksStatusEntryImpl instances ever created, but it's a reasonable
compromise between memory and runtime efficiency. In contrast to that,
synchronizing map access would have put a major runtime performance
penalty on parsing.
Fixes#32194.
Also extend DescriptorReader#readDescriptors to support .gz-compressed
files which will be necessary to process files rsync'ed from BridgeDB.
And maybe it's useful for other purposes, too.
Implements part of #19332.
Fix leaking resource in TorperfResultImpl.java using
try-with-resource statement.
This fix is related to analysis on metrics-lib using sonarqube
Implements part of #30544
Signed-off-by: fava <fava@libertymail.net>
Fix leaking resource in ExitListEntryImpl.java using
try-with-resource statement.
This fix is related to analysis on metrics-lib using sonarqube
Implements part of #30544
Fix leaking resource in DescriptorReaderImpl.java using
try-with-resource statement.
This fix is related to analysis on metrics-lib using sonarqube
Implements part of #30544
Turns out that updating all dependencies, including those in
metrics-web and exonerator using servlets and JSPs, is much harder
than expected. We decided to revert all these changes for now, so that
we can merge patches again. We're going to investigate alternatives
like Ant + Ivy, Maven, or Gradle in the near future.
Also upgrade to latest metrics-base.
Note that Checkstyle is excluded from this update, because there's a
yet unresolved issue with the new version: ("Unable to create Root
Module") that we'll have to address in a separate patch. But given
that Checkstyle is not required for the build it's okay to keep the
old version for now. It'll be in the release tarball.
We're using a regular expression on the first 100 characters of a
descriptor to recognize bandwidth files. More specifically, if a
descriptor starts with ten digits followed by a newline, we parse it
as a bandwidth file. (This is ugly, but the legacy bandwidth file
format doesn't give us much of a choice.)
This regular expression is broken. The regular expression we want is
one that matches the first 100 characters of a descriptor, which ours
didn't do.
More detailed explanation of the code change:
- We don't need to start the pattern with `^`, because the regular
expression needs to match the whole string anyway.
- The `(?s)` part enables the dotall mode: "In dotall mode, the
expression . matches any character, including a line terminator. By
default this expression does not match line terminators. Dotall
mode can also be enabled via the embedded flag expression (?s).
(The s is a mnemonic for "single-line" mode, which is what this is
called in Perl.)"
- We need to end the pattern with `.*` to match any characters
following the first newline, which also includes newlines due to
the previously enabled dotall mode.
Fixes#30369.