From 999e5b2a29ff6c88b54a090e3ca00532ad5994ae Mon Sep 17 00:00:00 2001 From: David Waltermire Date: Sat, 7 Sep 2024 11:50:15 -0400 Subject: [PATCH] Improved error logging for unexpected constraint validation errors, which were not being logged. --- .../FindingCollectingConstraintValidationHandler.java | 6 ++++++ metaschema-maven-plugin/pom.xml | 3 +-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/FindingCollectingConstraintValidationHandler.java b/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/FindingCollectingConstraintValidationHandler.java index c2d471b14..bb06900e1 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/FindingCollectingConstraintValidationHandler.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/FindingCollectingConstraintValidationHandler.java @@ -16,15 +16,20 @@ import gov.nist.secauto.metaschema.core.util.CollectionUtil; import gov.nist.secauto.metaschema.core.util.ObjectUtils; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import java.util.LinkedList; import java.util.List; import java.util.regex.Pattern; import edu.umd.cs.findbugs.annotations.NonNull; +@SuppressWarnings("PMD.CouplingBetweenObjects") public class FindingCollectingConstraintValidationHandler extends AbstractConstraintValidationHandler implements IValidationResult { + private static final Logger LOGGER = LogManager.getLogger(FindingCollectingConstraintValidationHandler.class); @NonNull private final List findings = new LinkedList<>(); @NonNull @@ -263,6 +268,7 @@ public void handleError( INodeItem node, String message, Throwable exception) { + LOGGER.atError().withThrowable(exception).log(message); addFinding(ConstraintValidationFinding.builder(constraint, node) .kind(Kind.FAIL) .severity(Level.CRITICAL) diff --git a/metaschema-maven-plugin/pom.xml b/metaschema-maven-plugin/pom.xml index 29c9b65af..ae84d4c53 100644 --- a/metaschema-maven-plugin/pom.xml +++ b/metaschema-maven-plugin/pom.xml @@ -26,7 +26,7 @@ ${scm.url}/tree/develop/metaschema-maven-plugin HEAD - + @@ -75,7 +75,6 @@ org.apache.maven.plugin-tools maven-plugin-annotations - ${dependency.maven-plugin-tools.version} provided true