As discussed on #34031, we should avoid keeping a map of known failure
types in the sources and simply put together the error code in the
format we want.
This patch implements that change.
We are detecting descriptor types of parsed descriptors by either
content or file name. In some cases, if we downloaded descriptors from
web servers, there is no file name. In other cases the file name can
match more than one descriptor type. It seems most robust to move the
file name checks to the end, which includes web server access logs and
OnionPerf analysis files.
It seemed like a good idea to decompress xz-compressed files before
handing over decompressed bytes to descriptor implementations.
However, our web logs expect descriptor bytes to be in compressed
form, and now they're unhappy about receiving uncompressed bytes.
Changing this back and teaching OnionPerf analysis files to expect
compressed bytes, too. Found by running CollecTor's unit tests.
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.