Skip to content

Commit acbb1c0

Browse files
committed
synchronized validation to avoid concurrency issues like FWK005
1 parent 4f70bda commit acbb1c0

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/main/java/org/mitre/stix/STIXSchema.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,12 @@ public boolean validate(String xmlText) throws SAXException {
256256
}
257257

258258
try {
259-
validator.validate(new StreamSource(new ByteArrayInputStream(
260-
xmlText.getBytes(StandardCharsets.UTF_8))));
259+
// synchronized to avoid org.xml.sax.SAXException: FWK005 parse may
260+
// not be called while parsing.
261+
synchronized (this) {
262+
validator.validate(new StreamSource(new ByteArrayInputStream(
263+
xmlText.getBytes(StandardCharsets.UTF_8))));
264+
}
261265
} catch (IOException e) {
262266
throw new RuntimeException(e);
263267
} catch (SAXException e) {

0 commit comments

Comments
 (0)