NPE at org.jboss.resteasy.plugins.providers.multipart.Mime4JWorkaround$CustomTempFileStorageProvider.createStorageOutputStream(Mime4JWorkaround.java:146) after applying EAP 7.4 Update 10
Environment
- Red Hat JBoss Enterprise Application Platform (EAP) 7.4 Update 10
- Red Hat Single Sign-On (RHSSO) 7.6.3
Issue
- After updating to JBoss EAP 7.4 Update 10 (from Update 9) and validating, we are running into a NullPointerException in
org.jboss.resteasy.plugins.providers.multipart.Mime4JWorkaround.CustomTempFileStorageProvider#createStorageOutputStream. The java.lang.NullPointerException is not logged and is only returned in the response with a 400 error status.
Resolution
Apply Update 11 or later where This content is not included.JBEAP-24719 is fixed.
Until then, set this system property as a workaround:
-Dorg.apache.james.mime4j.defaultStorageProvider=org.apache.james.mime4j.storage.TempFileStorageProvider
Root Cause
This content is not included.JBEAP-24719 / This content is not included.RESTEASY-3290 - NPE at org.jboss.resteasy.plugins.providers.multipart.Mime4JWorkaround$CustomTempFileStorageProvider.createStorageOutputStream(Mime4JWorkaround.java:146)
Diagnostic Steps
- Reproduce with byteman using a rule like below:
RULE writeException
CLASS ^org.jboss.resteasy.core.SynchronousDispatcher
METHOD writeException
AT EXIT
IF TRUE
DO
$3.printStackTrace()
ENDRULE
RULE brinit
CLASS ^org.jboss.resteasy.specimpl.BuiltResponse
METHOD <init>
AT EXIT
IF TRUE
DO traceStack("GSS BuiltResponse.init: " + $1 + "\n")
ENDRULE
RULE restEasysetstatus
CLASS ^org.jboss.resteasy.specimpl.BuiltResponse
METHOD setStatus
AT EXIT
IF TRUE
DO traceStack("GSS BuiltResponse.setStatus: " + $1 + "\n")
ENDRULE
RULE HttpServerExchange
CLASS io.undertow.server.HttpServerExchange
METHOD setStatusCode
AT EXIT
IF TRUE
DO traceStack("GSS HttpServerExchange.setStatusCode: " + $1 + "\n")
ENDRULE
- You should then be able to see the NullPointerException logged to confirm it is the cause:
14:41:35,543 ERROR [stderr] (default task-1) Caused by: java.lang.NullPointerException
14:41:35,543 ERROR [stderr] (default task-1) at org.jboss.resteasy.plugins.providers.multipart.Mime4JWorkaround$CustomTempFileStorageProvider.createStorageOutputStream(Mime4JWorkaround.java:134)
14:41:35,543 ERROR [stderr] (default task-1) at org.apache.james.mime4j.storage.ThresholdStorageProvider$ThresholdStorageOutputStream.write0(ThresholdStorageProvider.java:113)
14:41:35,543 ERROR [stderr] (default task-1) at org.apache.james.mime4j.storage.StorageOutputStream.write(StorageOutputStream.java:119)
14:41:35,543 ERROR [stderr] (default task-1) at org.apache.james.mime4j.util.ContentUtil.copy(ContentUtil.java:84)
14:41:35,543 ERROR [stderr] (default task-1) at org.apache.james.mime4j.storage.AbstractStorageProvider.store(AbstractStorageProvider.java:57)
14:41:35,543 ERROR [stderr] (default task-1) at org.apache.james.mime4j.storage.StorageBodyFactory.binaryBody(StorageBodyFactory.java:94)
14:41:35,543 ERROR [stderr] (default task-1) at org.jboss.resteasy.plugins.providers.multipart.Mime4jWorkaroundBinaryEntityBuilder.body(Mime4jWorkaroundBinaryEntityBuilder.java:177)
14:41:35,543 ERROR [stderr] (default task-1) at org.apache.james.mime4j.parser.MimeStreamParser.parse(MimeStreamParser.java:133)
14:41:35,543 ERROR [stderr] (default task-1) at org.jboss.resteasy.plugins.providers.multipart.Mime4JWorkaround.parseMessage(Mime4JWorkaround.java:95)
14:41:35,543 ERROR [stderr] (default task-1) at org.jboss.resteasy.plugins.providers.multipart.MultipartInputImpl.parse(MultipartInputImpl.java:102)
14:41:35,543 ERROR [stderr] (default task-1) at org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataReader.readFrom(MultipartFormDataReader.java:53)
14:41:35,543 ERROR [stderr] (default task-1) at org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataReader.readFrom(MultipartFormDataReader.java:23)
14:41:35,543 ERROR [stderr] (default task-1) at org.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.readFrom(AbstractReaderInterceptorContext.java:66)
14:41:35,543 ERROR [stderr] (default task-1) at org.jboss.resteasy.core.interception.ServerReaderInterceptorContext.readFrom(ServerReaderInterceptorContext.java:61)
14:41:35,543 ERROR [stderr] (default task-1) at org.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.proceed(AbstractReaderInterceptorContext.java:56)
14:41:35,543 ERROR [stderr] (default task-1) at org.jboss.resteasy.security.doseta.DigitalVerificationInterceptor.aroundReadFrom(DigitalVerificationInterceptor.java:36)
14:41:35,543 ERROR [stderr] (default task-1) at org.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.proceed(AbstractReaderInterceptorContext.java:59)
14:41:35,543 ERROR [stderr] (default task-1) at org.jboss.resteasy.core.MessageBodyParameterInjector.inject(MessageBodyParameterInjector.java:198)
14:41:35,543 ERROR [stderr] (default task-1) ... 65 more
Components
Category
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.