Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 8 additions & 21 deletions src/main/java/com/amazon/ion/impl/_Private_IonReaderFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,9 @@
import com.amazon.ion.IonTextReader;
import com.amazon.ion.IonValue;
import com.amazon.ion.system.IonReaderBuilder;
import com.amazon.ion.util.IonStreamUtils;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.util.zip.GZIPInputStream;

/**
* NOT FOR APPLICATION USE!
Expand Down Expand Up @@ -205,34 +202,24 @@ public static final IonReader makeSystemReaderBinary(IonReaderBuilder builder, b
// helper functions
//

// Invariant: these helpers must not detect or decompress any wrapper format, GZIP included.
// Unwrapping belongs exclusively to the InputStreamInterceptor list applied in
// _Private_IonReaderBuilder.buildReader. Input that no interceptor claims, and that is not
// binary Ion, is routed here as a fallback, so any decompression added below would sit outside
// the interceptor list and therefore outside the builder configuration that governs it.

private static UnifiedInputStreamX makeUnifiedStream(byte[] bytes,
int offset,
int length)
throws IOException
{
UnifiedInputStreamX uis;
if (IonStreamUtils.isGzip(bytes, offset, length))
{
ByteArrayInputStream baos =
new ByteArrayInputStream(bytes, offset, length);
GZIPInputStream gzip = new GZIPInputStream(baos);
uis = UnifiedInputStreamX.makeStream(gzip);
}
else
{
uis = UnifiedInputStreamX.makeStream(bytes, offset, length);
}
return uis;
return UnifiedInputStreamX.makeStream(bytes, offset, length);
}

private static UnifiedInputStreamX makeUnifiedStream(InputStream in)
throws IOException
{
in.getClass(); // Force NPE

// TODO avoid multiple wrapping streams, use the UIS for the pushback
in = IonStreamUtils.unGzip(in);
UnifiedInputStreamX uis = UnifiedInputStreamX.makeStream(in);
return uis;
return UnifiedInputStreamX.makeStream(in);
}
}
Loading
Loading