Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into SRU2024_v10
Browse files Browse the repository at this point in the history
  • Loading branch information
zubri committed Jan 7, 2025
2 parents 62b5b73 + 645d5dd commit 7734356
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 7 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ jobs:
uses: gradle/actions/setup-gradle@v4

- name: Build with Gradle Wrapper
run: ./gradlew build
run: ./gradlew -Dorg.gradle.jvmargs="-Xms512m -Xmx7g" compileJava compileTestJava

- name: Run test
run: ./gradlew test --info

# This job generates and submits a dependency graph, enabling Dependabot Alerts for all project dependencies.
# We only do it for the SRU2024_v10 branch to avoid spamming the Dependabot alerts for the legacy Java 8 code.
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Prowide ISO 20022 - CHANGELOG

#### 10.2.7 - SNAPSHOT
* Enhanced the MX parser log verbosity when parsing malformed content

#### 10.2.6 - January 2025
* Changed the `MxParseUtils` findByTags and findByPath methods to return the element values instead of the XML stream object

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ public static AbstractMX parse(

return mx.orElse(null);

} catch (AssertionError e) {
// depending on the jaxb implementation used, the assertion error can be thrown when the XML is not valid
log.log(Level.SEVERE, "Error parsing XML", e);
return null;
} catch (final Exception e) {
MxParseUtils.handleParseException(e);
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@
* @since 9.2.1
*/
public class NamespaceAndElementFilter extends XMLFilterImpl {
private static final transient Logger log = Logger.getLogger(NamespaceAndElementFilter.class.getName());
private static final Logger log = Logger.getLogger(NamespaceAndElementFilter.class.getName());

private String mainNamespace;
private boolean inElementToPropagate = false;
private String localNameToPropagate;
private final String localNameToPropagate;
private boolean inInnerElementToSkip = false;
private String localNameToSkip;
private boolean unbindNamespace;
private final boolean unbindNamespace;

/**
* @param localName the XML's element to propagate
Expand Down Expand Up @@ -91,7 +91,10 @@ public void startElement(String namespace, String localName, String prefix, Attr
try {
super.startElement(namespaceToPropagate, localName, prefix, attributes);
} catch (Exception e) {
log.log(Level.WARNING, "Error parsing " + localName + " [" + namespace + "] element", e);
log.warning("Error parsing " + localName + " [" + namespace + "] element: " + exceptionMessage(e));
if (log.isLoggable(Level.FINEST)) {
log.log(Level.FINEST, "Error parsing " + localName + " [" + namespace + "] element", e);
}
}
} else {
// we have found an element within the structure to propagate with a not recognized namespace
Expand Down Expand Up @@ -150,7 +153,10 @@ public void endElement(String namespace, String localName, String prefix) throws
try {
super.endElement(namespaceToPropagate, localName, prefix);
} catch (Exception e) {
log.log(Level.WARNING, "Error parsing " + localName + " [" + namespace + "] element", e);
log.warning("Error parsing " + localName + " [" + namespace + "] element: " + exceptionMessage(e));
if (log.isLoggable(Level.FINEST)) {
log.log(Level.FINEST, "Error parsing " + localName + " [" + namespace + "] element", e);
}
}
}
}
Expand All @@ -169,9 +175,23 @@ public void startPrefixMapping(String prefix, String url) throws SAXException {
try {
super.startPrefixMapping(prefix, url);
} catch (Exception e) {
log.log(Level.WARNING, "Error parsing " + prefix + " [" + url + "] prefix mapping", e);
log.warning("Error parsing " + prefix + " [" + url + "] prefix mapping: " + exceptionMessage(e));
if (log.isLoggable(Level.FINEST)) {
log.log(Level.FINEST, "Error parsing " + prefix + " [" + url + "] prefix mapping", e);
}
}
}
}
}

private static String exceptionMessage(Exception e) {
String message = e.getMessage();
if (message == null && e.getCause() != null) {
message = e.getCause().getMessage();
}
if (message == null) {
message = e.getClass().getSimpleName();
}
return message;
}
}

0 comments on commit 7734356

Please sign in to comment.