Skip to content

We got NPE if the body is empty for post request in the request validation #144

@stevehu

Description

@stevehu

The following error was captured from one of the users. As this is a known scenario, we need to add a check in the code to handler it with a proper error code. The graphql and hybrid hander will be addressed at the same time.

xhistory_1  | 21:22:23.428 [XNIO-1 task-1]  i7RNA6CkQ_G4TcyF3Rm6PA DEBUG c.n.openapi.ApiNormalisedPath <init> - path =/correlations
xhistory_1  | 21:22:23.428 [XNIO-1 task-1]  i7RNA6CkQ_G4TcyF3Rm6PA DEBUG c.n.openapi.ApiNormalisedPath <init> - normalised = /correlations
xhistory_1  | 21:22:23.428 [XNIO-1 task-1]  i7RNA6CkQ_G4TcyF3Rm6PA DEBUG c.n.openapi.ApiNormalisedPath <init> - path =/correlations
xhistory_1  | 21:22:23.428 [XNIO-1 task-1]  i7RNA6CkQ_G4TcyF3Rm6PA DEBUG c.n.openapi.ApiNormalisedPath <init> - normalised = /correlations
xhistory_1  | 21:22:23.431 [XNIO-1 task-1]  i7RNA6CkQ_G4TcyF3Rm6PA DEBUG c.n.openapi.ApiNormalisedPath <init> - path =/correlations
xhistory_1  | 21:22:23.431 [XNIO-1 task-1]  i7RNA6CkQ_G4TcyF3Rm6PA DEBUG c.n.openapi.ApiNormalisedPath <init> - normalised = /correlations
xhistory_1  | 21:22:23.432 [XNIO-1 task-1]  i7RNA6CkQ_G4TcyF3Rm6PA ERROR c.n.exception.ExceptionHandler handleRequest - Exception:
xhistory_1  | java.lang.NullPointerException: null
xhistory_1  | 	at com.networknt.openapi.RequestValidator.validateRequestBody(RequestValidator.java:126)
xhistory_1  | 	at com.networknt.openapi.RequestValidator.validateRequest(RequestValidator.java:93)
xhistory_1  | 	at com.networknt.openapi.ValidatorHandler.handleRequest(ValidatorHandler.java:84)
xhistory_1  | 	at com.networknt.handler.Handler.next(Handler.java:208)
xhistory_1  | 	at com.networknt.handler.Handler.next(Handler.java:229)
xhistory_1  | 	at com.networknt.audit.AuditHandler.next(AuditHandler.java:154)
xhistory_1  | 	at com.networknt.audit.AuditHandler.handleRequest(AuditHandler.java:143)
xhistory_1  | 	at com.networknt.handler.Handler.next(Handler.java:208)
xhistory_1  | 	at com.networknt.handler.Handler.next(Handler.java:229)
xhistory_1  | 	at com.networknt.body.BodyHandler.handleRequest(BodyHandler.java:123)
xhistory_1  | 	at com.networknt.handler.Handler.next(Handler.java:208)
xhistory_1  | 	at com.networknt.handler.Handler.next(Handler.java:229)
xhistory_1  | 	at com.networknt.openapi.OpenApiHandler.handleRequest(OpenApiHandler.java:108)
xhistory_1  | 	at com.networknt.handler.Handler.next(Handler.java:208)
xhistory_1  | 	at com.networknt.handler.Handler.next(Handler.java:229)
xhistory_1  | 	at com.networknt.correlation.CorrelationHandler.handleRequest(CorrelationHandler.java:77)
xhistory_1  | 	at com.networknt.handler.Handler.next(Handler.java:208)
xhistory_1  | 	at com.networknt.handler.Handler.next(Handler.java:229)
xhistory_1  | 	at com.networknt.traceability.TraceabilityHandler.handleRequest(TraceabilityHandler.java:66)
xhistory_1  | 	at com.networknt.handler.Handler.next(Handler.java:208)
xhistory_1  | 	at com.networknt.handler.Handler.next(Handler.java:229)
xhistory_1  | 	at com.networknt.exception.ExceptionHandler.handleRequest(ExceptionHandler.java:76)
xhistory_1  | 	at io.undertow.server.Connectors.executeRootHandler(Connectors.java:370)
xhistory_1  | 	at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:830)
xhistory_1  | 	at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
xhistory_1  | 	at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2019)
xhistory_1  | 	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1558)
xhistory_1  | 	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1449)
xhistory_1  | 	at java.base/java.lang.Thread.run(Unknown Source)
xhistory_1  | 21:22:23.433 [XNIO-1 task-1]  i7RNA6CkQ_G4TcyF3Rm6PA ERROR c.networknt.handler.LightHttpHandler setExchangeStatus - {"statusCode":500,"code":"ERR10010","message":"RUNTIME_EXCEPTION","description":"Unexpected runtime exception","severity":"ERROR"} at com.networknt.handler.LightHttpHandler.setExchangeStatus(LightHttpHandler.java:67)
~~~~

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions