Skip to content

Commit b2431b6

Browse files
committed
Replace ParseError with MultiException in FuzzData
- Consolidated exception handling under `handleKnownException` to manage both `MultiException` and `ParseError`. This is because MultiException.toss can throw either a ParseError or a MultiException - Adjusted related method and variable names for consistency. DAFFODIL-3075
1 parent 32bc90f commit b2431b6

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

  • daffodil-core/src/main/scala/org/apache/daffodil/core/util

daffodil-core/src/main/scala/org/apache/daffodil/core/util/FuzzData.scala

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import scala.xml.Elem
2323
import scala.xml.Node
2424

2525
import org.apache.daffodil.lib.exceptions.Assert
26+
import org.apache.daffodil.lib.exceptions.MultiException
2627
import org.apache.daffodil.lib.util.Misc.getAMessage
2728
import org.apache.daffodil.lib.xml.XMLUtils
2829
import org.apache.daffodil.lib.xml.XMLUtils.XMLDifferenceException
@@ -146,7 +147,11 @@ class FuzzParseTester(
146147

147148
val okParses = new mutable.HashSet[(Node, Array[Byte], XMLDifferenceException)]
148149

149-
protected def handleParseError(p: ParseError, testData: Array[Byte], i: Int) = {
150+
protected def handleKnownException(
151+
ex: Exception,
152+
testData: Array[Byte],
153+
i: Int
154+
) = {
150155
// do nothing by default
151156
}
152157

@@ -175,8 +180,8 @@ class FuzzParseTester(
175180
try {
176181
TestUtils.runDataProcessorOnInputStream(p, bais, areTracing = false)
177182
} catch {
178-
case p: ParseError => {
179-
handleParseError(p, testData, i)
183+
case ex @ (_: MultiException[Throwable] @unchecked | _: ParseError) => {
184+
handleKnownException(ex, testData, i)
180185
(null, null)
181186
}
182187
case t: Throwable => {
@@ -207,13 +212,17 @@ class LayerParseTester(
207212

208213
var shouldFail = false
209214

210-
override def handleParseError(p: ParseError, data: Array[Byte], nth: Int): Unit = {
211-
val msg = getAMessage(p)
215+
override def handleKnownException(
216+
ex: Exception,
217+
data: Array[Byte],
218+
nth: Int
219+
): Unit = {
220+
val msg = getAMessage(ex)
212221
if (excludes.exists { msg.contains(_) }) {
213222
// we know about this one
214223
} else {
215224
// new parse error type
216-
println(s"trial $nth produced $p")
225+
println(s"trial $nth produced $ex")
217226
shouldFail = true
218227
}
219228
}

0 commit comments

Comments
 (0)