stevedlawrence commented on a change in pull request #529:
URL: https://github.com/apache/daffodil/pull/529#discussion_r613232327
##########
File path:
daffodil-test/src/test/resources/org/apache/daffodil/layers/layers.tdml
##########
@@ -383,7 +383,7 @@ jones,arya,cat,1986-02-19
We gzip that, and then we must prepend that with the length (as a binary
4-byte int) before we base64 encode.
-->
- <tdml:documentPart type="text"
replaceDFDLEntities="true"><![CDATA[AAAAcx+LCAAAAAAAAAAtyUEKgCAQheG94E1mIDWittG+M0xpaNQIo5tuX0Kb98P7LioVjiTf3sn7%CR;%LF;K8CyzlqVO9UIkrcgFTYh9pnBTOOInUPba3XmyOX7WiEGlqfxgJ1B6xpzKEDyEOxUf7JoJq1e/RI4%CR;%LF;wXIAAAA=--END--]]></tdml:documentPart>
+ <tdml:documentPart type="text"
replaceDFDLEntities="true"><![CDATA[AAAAcx+LCAAAAAAAAP8tyUEKgCAQheG94E1mIDWittG+M0xpaNQIo5tuX0Kb98P7LioVjiTf3sn7%CR;%LF;K8CyzlqVO9UIkrcgFTYh9pnBTOOInUPba3XmyOX7WiEGlqfxgJ1B6xpzKEDyEOxUf7JoJq1e/RI4%CR;%LF;wXIAAAA=--END--]]></tdml:documentPart>
Review comment:
I was thinking one alternative would be to create something like a
``GZIPFixerOutputStream`` that acts as a proxy betwen the GZIPOutputStream and
the underlying output stream. This "fixer" could change the 10th byte to 255
and pass all other bytes through unchanged, so regardless of the java version
we get consistent gzip output.
Might look something like this:
```scala
class GZIPFixerOutputStream(os: OutputStream) extends OutputStream {
private val position = 0
override def write(byte: Byte) {
if (position == 10) os.write(255) else os.write(byte)
postition += 1
}
}
class GZIPTransformer {
...
override protected def wrapLayerEncoder(jos: java.io.OutputStream):
java.io.OutputStream = {
val fixer = new GZIPFixerOutputStream(jos)
val s = new java.util.zip.GZIPOutputStream(fix)
s
}
}
```
It's a bit of a hack, but at least we get consistent behavior regardless of
the Java version?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]