From 8079d2531e561ad5dbbfe9e8dc4b818d694d57a6 Mon Sep 17 00:00:00 2001 From: Mark Payne Date: Wed, 23 Oct 2019 20:14:35 -0400 Subject: [PATCH] NIFI-6805, NIFI-6806: Updated toString() of StandardControllerServiceNode so that it includes the component's type and UUID, updated the more generic Exception Mappers to include stack traces regardless of the log level that is enabled This closes #3840 Signed-off-by: Mike Thomsen --- .../StandardControllerServiceNode.java | 21 +++++++------------ .../IllegalArgumentExceptionMapper.java | 9 ++++---- .../config/IllegalStateExceptionMapper.java | 13 ++++-------- .../api/config/NiFiCoreExceptionMapper.java | 15 +++++-------- .../config/WebApplicationExceptionMapper.java | 13 +++++------- 5 files changed, 26 insertions(+), 45 deletions(-) diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/service/StandardControllerServiceNode.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/service/StandardControllerServiceNode.java index f2ce848ec5..1ce13c3837 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/service/StandardControllerServiceNode.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/service/StandardControllerServiceNode.java @@ -420,9 +420,9 @@ public class StandardControllerServiceNode extends AbstractComponentNode impleme final ValidationStatus validationStatus = getValidationStatus(); if (validationStatus != ValidationStatus.VALID) { - LOG.debug("Cannot enable {} because it is not currently valid. Will try again in 5 seconds", StandardControllerServiceNode.this); - scheduler.schedule(this, 5, TimeUnit.SECONDS); - future.completeExceptionally(new ControllerServiceNotValidException(this + " cannot be enabled because it is not currently valid. Will try again in 5 seconds.")); + LOG.debug("Cannot enable {} because it is not currently valid. (Validation State is {}). Will try again in 1 second", StandardControllerServiceNode.this, getValidationState()); + scheduler.schedule(this, 1, TimeUnit.SECONDS); + future.complete(null); return; } @@ -569,19 +569,14 @@ public class StandardControllerServiceNode extends AbstractComponentNode impleme @Override public String toString() { - String bundleCoordinate; - try { - bundleCoordinate = controllerServiceHolder.get().getBundleCoordinate().toString(); - } catch (NullPointerException e) { - bundleCoordinate = "null"; - } - return "StandardControllerServiceNode{" + - "controllerServiceHolder=" + bundleCoordinate + + final ControllerServiceDetails details = controllerServiceHolder.get(); + final String bundleCoordinate = details == null ? "null" : String.valueOf(details.getBundleCoordinate()); + return "StandardControllerServiceNode[" + + "service=" + super.toString() + ", versionedComponentId=" + versionedComponentId + - ", comment='" + comment + '\'' + ", processGroup=" + processGroup + ", active=" + active + - '}'; + ']'; } @Override diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/config/IllegalArgumentExceptionMapper.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/config/IllegalArgumentExceptionMapper.java index e9edd8f092..5151a41f76 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/config/IllegalArgumentExceptionMapper.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/config/IllegalArgumentExceptionMapper.java @@ -16,12 +16,12 @@ */ package org.apache.nifi.web.api.config; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import javax.ws.rs.core.Response; import javax.ws.rs.ext.ExceptionMapper; import javax.ws.rs.ext.Provider; -import org.apache.nifi.util.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * Maps web application exceptions into client responses. @@ -34,8 +34,7 @@ public class IllegalArgumentExceptionMapper implements ExceptionMapper