[Geoserver-devel] [JIRA] (GEOS-10522) Failure in @ExceptionHandler No input String specified

Jody Garnett created an issue

GeoServer / BugGEOS-10522

Failure in @ExceptionHandler No input String specified

Issue Type:

BugBug

Assignee:

Unassigned

Components:

REST

Created:

01/Jun/22 8:20 PM

Environment:

Docer / Ubuntu / Java 8

Logging of requests enabled

Priority:

MediumMedium

Reporter:

Jody Garnett

I am trouble shooting a failure in the REST API where exceptions are being gobbled up and not reported.

01 009 18:09:54 WARN   [annotation.ExceptionHandlerExceptionResolver] - Failure in @ExceptionHandler org.geoserver.rest.RestControllerAdvice#handleGeneralException(Exception, HttpServletRequest, HttpServletResponse, OutputStream)
java.lang.IllegalArgumentException: No input String specified
	at org.springframework.util.Assert.notNull(Assert.java:201)
	at org.springframework.util.StreamUtils.copy(StreamUtils.java:142)
	at org.geoserver.rest.RestControllerAdvice.handleGeneralException(RestControllerAdvice.java:126

The above warning is due to not performing a null check on e.getMessage():

    public void handleGeneralException(
            Exception e, HttpServletRequest request, HttpServletResponse response, OutputStream os)
            throws Exception {
        // if there is a OGC request active, the exception was not meant for this dispatcher,
        // nor it was if it's a security exception, in this case let servlet filters handle it
        // instead
        if (Dispatcher.REQUEST.get() != null
                || e instanceof AuthenticationException
                || e instanceof AccessDeniedException) {
            throw e;
        }
        LOGGER.log(Level.SEVERE, e.getMessage(), e);
        notifyExceptionToCallbacks(request, response, e);

        response.setStatus(500);
        response.setContentType(MediaType.TEXT_PLAIN_VALUE);
        StreamUtils.copy(e.getMessage(), StandardCharsets.UTF_8, os);
    }

Add Comment

Add Comment

Get Jira notifications on your phone! Download the Jira Cloud app for Android or iOS


This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100199-sha1:4212c97)

Atlassian logo