Commit d4bb2852 authored by Karsten Loesing's avatar Karsten Loesing
Browse files

Change back how we treat xz-compressed 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.
parent 7efeec72
# Changes in version 2.??.? - 2020-??-??
* Minor changes
- Change back how we treat xz-compressed files by leaving
decompression to descriptor implementations.
# Changes in version 2.12.0 - 2020-04-30
......
......@@ -330,8 +330,6 @@ public class DescriptorReaderImpl implements DescriptorReader {
InputStream is = fis;
if (file.getName().endsWith(".gz")) {
is = new GzipCompressorInputStream(fis);
} else if (file.getName().endsWith(".xz")) {
is = new XZCompressorInputStream(fis);
}
byte[] rawDescriptorBytes = IOUtils.toByteArray(is);
if (rawDescriptorBytes.length > 0) {
......
......@@ -7,8 +7,13 @@ import org.torproject.descriptor.Descriptor;
import org.torproject.descriptor.DescriptorParseException;
import org.torproject.descriptor.impl.TorperfResultImpl;
import org.apache.commons.compress.compressors.xz.XZCompressorInputStream;
import org.apache.commons.compress.utils.IOUtils;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
......@@ -66,8 +71,13 @@ public class OnionPerfAnalysisConverter {
public List<Descriptor> asTorperfResults() throws DescriptorParseException {
ParsedOnionPerfAnalysis parsedOnionPerfAnalysis;
try {
parsedOnionPerfAnalysis = ParsedOnionPerfAnalysis.fromBytes(
InputStream compressedInputStream = new ByteArrayInputStream(
this.rawDescriptorBytes);
InputStream decompressedInputStream = new XZCompressorInputStream(
compressedInputStream);
byte[] decompressedBytes = IOUtils.toByteArray(decompressedInputStream);
parsedOnionPerfAnalysis = ParsedOnionPerfAnalysis.fromBytes(
decompressedBytes);
} catch (IOException ioException) {
throw new DescriptorParseException("Ran into an I/O error while "
+ "attempting to parse an OnionPerf analysis document.",
......
......@@ -10,7 +10,6 @@ import org.torproject.descriptor.Descriptor;
import org.torproject.descriptor.DescriptorParseException;
import org.torproject.descriptor.TorperfResult;
import org.apache.commons.compress.compressors.xz.XZCompressorInputStream;
import org.apache.commons.compress.utils.IOUtils;
import org.junit.Test;
......@@ -88,9 +87,7 @@ public class OnionPerfAnalysisConverterTest {
assertNotNull(resouce);
InputStream compressedInputStream = resouce.openStream();
assertNotNull(compressedInputStream);
InputStream uncompressedInputStream = new XZCompressorInputStream(
compressedInputStream);
byte[] rawDescriptorBytes = IOUtils.toByteArray(uncompressedInputStream);
byte[] rawDescriptorBytes = IOUtils.toByteArray(compressedInputStream);
OnionPerfAnalysisConverter onionPerfAnalysisConverter
= new OnionPerfAnalysisConverter(rawDescriptorBytes, null);
for (Descriptor descriptor
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment