You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@daffodil.apache.org by mb...@apache.org on 2018/05/07 21:04:21 UTC
[incubator-daffodil] branch master updated: Fix so trace works even
when layering is being used.
This is an automated email from the ASF dual-hosted git repository.
mbeckerle pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-daffodil.git
The following commit(s) were added to refs/heads/master by this push:
new 08fd62b Fix so trace works even when layering is being used.
08fd62b is described below
commit 08fd62b23d05ae7c991795b724749e607541db29
Author: Michael Beckerle <mb...@tresys.com>
AuthorDate: Mon May 7 12:24:54 2018 -0400
Fix so trace works even when layering is being used.
DAFFODIL-1935
---
.../src/test/scala/org/apache/daffodil/util/TestUtils.scala | 12 ++++++++----
.../org/apache/daffodil/io/DataOutputStreamImplMixin.scala | 13 +++++++++----
.../scala/org/apache/daffodil/layers/LayerTransformer.scala | 2 ++
3 files changed, 19 insertions(+), 8 deletions(-)
diff --git a/daffodil-core/src/test/scala/org/apache/daffodil/util/TestUtils.scala b/daffodil-core/src/test/scala/org/apache/daffodil/util/TestUtils.scala
index a26aabf..70c69d2 100644
--- a/daffodil-core/src/test/scala/org/apache/daffodil/util/TestUtils.scala
+++ b/daffodil-core/src/test/scala/org/apache/daffodil/util/TestUtils.scala
@@ -79,8 +79,8 @@ object TestUtils {
throw new FileNotFoundException("Couldn't find file " + f + " relative to " + cwd + ".")
}
- def testString(testSchema: Node, data: String, isTracing: Boolean = false) = {
- runSchemaOnData(testSchema, Misc.stringToReadableByteChannel(data), isTracing)
+ def testString(testSchema: Node, data: String, areTracing: Boolean = false) = {
+ runSchemaOnData(testSchema, Misc.stringToReadableByteChannel(data), areTracing)
}
def testBinary(testSchema: Node, hexData: String, areTracing: Boolean = false): (DFDL.ParseResult, Node) = {
@@ -139,15 +139,19 @@ object TestUtils {
}
}
- def testUnparsingBinary(testSchema: scala.xml.Elem, infoset: Node, unparseTo: Array[Byte]) {
+ def testUnparsingBinary(testSchema: scala.xml.Elem, infoset: Node, unparseTo: Array[Byte], areTracing: Boolean = false) {
val compiler = Compiler()
val pf = compiler.compileNode(testSchema)
if (pf.isError) throwDiagnostics(pf.diagnostics)
- val u = pf.onPath("/")
+ val u = pf.onPath("/").asInstanceOf[DataProcessor]
if (u.isError) throwDiagnostics(u.getDiagnostics)
val outputStream = new java.io.ByteArrayOutputStream()
val out = java.nio.channels.Channels.newChannel(outputStream)
val inputter = new ScalaXMLInfosetInputter(infoset)
+ if (areTracing) {
+ u.setDebugger(builtInTracer)
+ u.setDebugging(true)
+ }
val actual = u.unparse(inputter, out)
if (actual.isProcessingError) throwDiagnostics(actual.getDiagnostics)
val unparsed = outputStream.toByteArray()
diff --git a/daffodil-io/src/main/scala/org/apache/daffodil/io/DataOutputStreamImplMixin.scala b/daffodil-io/src/main/scala/org/apache/daffodil/io/DataOutputStreamImplMixin.scala
index 72ed284..97e0b6f 100644
--- a/daffodil-io/src/main/scala/org/apache/daffodil/io/DataOutputStreamImplMixin.scala
+++ b/daffodil-io/src/main/scala/org/apache/daffodil/io/DataOutputStreamImplMixin.scala
@@ -304,7 +304,6 @@ trait DataOutputStreamImplMixin extends DataStreamCommonState
// turn debugging off
this.cst.debugging = false
debugOutputStream = Nope
- setJavaOutputStream(new ByteArrayOutputStream())
}
}
@@ -816,9 +815,15 @@ trait DataOutputStreamImplMixin extends DataStreamCommonState
}
final override def pastData(nBytesRequested: Int): ByteBuffer = {
- Assert.usage(isReadable)
- if (!areDebugging)
- throw new IllegalStateException("Must be debugging.")
+ Assert.usage(isReadable ||
+ // when unparsing trace/debug wants to access pastData from this DOS
+ // even after it has been closed. This is just a consequence of the
+ // creation and completion of DOS interacting with the DOS being
+ // created on the fly to implement layering, where we allocate a new
+ // DOS for the layer, and then later just drop it when the layer exits.
+ // At that point the layer is closed, but trace/debug still wants to print
+ // pastData from it as part of what it displays.
+ areDebugging)
Assert.usage(nBytesRequested >= 0)
if (debugOutputStream == Nope) {
ByteBuffer.allocate(0)
diff --git a/daffodil-runtime1/src/main/scala/org/apache/daffodil/layers/LayerTransformer.scala b/daffodil-runtime1/src/main/scala/org/apache/daffodil/layers/LayerTransformer.scala
index a5f7a6c..383a8c7 100644
--- a/daffodil-runtime1/src/main/scala/org/apache/daffodil/layers/LayerTransformer.scala
+++ b/daffodil-runtime1/src/main/scala/org/apache/daffodil/layers/LayerTransformer.scala
@@ -142,6 +142,7 @@ abstract class LayerTransformer()
val newDIS = ByteBufferDataInputStream(decodedInputStream, 0L)
newDIS.cst.setPriorBitOrder(BitOrder.MostSignificantBitFirst) // must initialize priorBitOrder
+ newDIS.setDebugging(s.areDebugging)
newDIS
}
@@ -156,6 +157,7 @@ abstract class LayerTransformer()
val newDOS = DirectOrBufferedDataOutputStream(encodedOutputStream, null)
newDOS.setPriorBitOrder(BitOrder.MostSignificantBitFirst)
newDOS.setAbsStartingBitPos0b(ULong(0L))
+ newDOS.setDebugging(s.areDebugging)
newDOS
}
--
To stop receiving notification emails like this one, please contact
mbeckerle@apache.org.