mirror of https://github.com/apache/nifi.git
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 <mthomsen@apache.org>
This commit is contained in:
parent
8771c35f4a
commit
8079d2531e
|
@ -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
|
||||
|
|
|
@ -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<IllegalAr
|
|||
@Override
|
||||
public Response toResponse(IllegalArgumentException exception) {
|
||||
// log the error
|
||||
logger.info(String.format("%s. Returning %s response.", exception, Response.Status.BAD_REQUEST));
|
||||
logger.debug(StringUtils.EMPTY, exception);
|
||||
logger.info("{}}. Returning {}} response.", exception, Response.Status.BAD_REQUEST, exception);
|
||||
|
||||
return Response.status(Response.Status.BAD_REQUEST).entity(exception.getMessage()).type("text/plain").build();
|
||||
}
|
||||
|
|
|
@ -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,12 +34,7 @@ public class IllegalStateExceptionMapper implements ExceptionMapper<IllegalState
|
|||
@Override
|
||||
public Response toResponse(IllegalStateException exception) {
|
||||
// log the error
|
||||
logger.info(String.format("%s. Returning %s response.", exception, Response.Status.CONFLICT));
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(StringUtils.EMPTY, exception);
|
||||
}
|
||||
|
||||
logger.warn("{}. Returning {} response.", exception, Response.Status.CONFLICT, exception);
|
||||
return Response.status(Response.Status.CONFLICT).entity(exception.getMessage()).type("text/plain").build();
|
||||
}
|
||||
|
||||
|
|
|
@ -16,14 +16,14 @@
|
|||
*/
|
||||
package org.apache.nifi.web.api.config;
|
||||
|
||||
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.apache.nifi.web.NiFiCoreException;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Maps NiFi core exceptions into client responses.
|
||||
*/
|
||||
|
@ -35,12 +35,7 @@ public class NiFiCoreExceptionMapper implements ExceptionMapper<NiFiCoreExceptio
|
|||
@Override
|
||||
public Response toResponse(NiFiCoreException exception) {
|
||||
// log the error
|
||||
logger.info(String.format("%s. Returning %s response.", exception, Response.Status.CONFLICT));
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(StringUtils.EMPTY, exception);
|
||||
}
|
||||
|
||||
logger.warn("{}. Returning {} response.", exception, Response.Status.CONFLICT, exception);
|
||||
return Response.status(Response.Status.CONFLICT).entity(exception.getMessage()).type("text/plain").build();
|
||||
}
|
||||
|
||||
|
|
|
@ -16,13 +16,14 @@
|
|||
*/
|
||||
package org.apache.nifi.web.api.config;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.ws.rs.WebApplicationException;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.ext.ExceptionMapper;
|
||||
import javax.ws.rs.ext.Provider;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Maps web application exceptions into client responses.
|
||||
|
@ -50,11 +51,7 @@ public class WebApplicationExceptionMapper implements ExceptionMapper<WebApplica
|
|||
final Response response = exception.getResponse();
|
||||
|
||||
// log the error
|
||||
logger.info(String.format("%s. Returning %s response.", exception, response.getStatus()));
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(StringUtils.EMPTY, exception);
|
||||
}
|
||||
logger.warn("{}. Returning {} response.", exception, response.getStatus(), exception);
|
||||
|
||||
// generate the response
|
||||
return Response.status(response.getStatus()).entity(message).type("text/plain").build();
|
||||
|
|
Loading…
Reference in New Issue