Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resteasy reactive: Fix NullPointerException when using multipart with optional value #19160

Merged
merged 1 commit into from
Aug 2, 2021

Conversation

andreas-eberle
Copy link
Contributor

Hi guys,

I noticed that resteasy reactive throws a NullPointerException when you do not upload every file in a multipart body. In my case, I have file upload fields which are optional. This worked fine with resteasy-multipart but with resteasy reactive I get the exception.

So this PR tries to fix this issue.

I also added a test to try to validate this. I basically copied one of the other tests and slightly modified it. However, I cannot get any of the tests to work on my Windows. I'll continue trying but maybe you guys have an idea what is the issue.

@quarkus-bot quarkus-bot bot added the area/rest label Aug 2, 2021
@gsmet gsmet requested a review from geoand August 2, 2021 09:15
@andreas-eberle andreas-eberle force-pushed the bugfix/multipart-nullpointer branch from b4e6f7e to 3edeeaf Compare August 2, 2021 09:23
@quarkus-bot
Copy link

quarkus-bot bot commented Aug 2, 2021

This workflow status is outdated as a new workflow run has been triggered.

Failing Jobs - Building 3edeeaf

Status Name Step Test failures Logs Raw logs
JVM Tests - JDK 11 Build Test failures Logs Raw logs
JVM Tests - JDK 11 Windows Build Test failures Logs Raw logs
JVM Tests - JDK 16 Build Test failures Logs Raw logs

Full information is available in the Build summary check run.

Test Failures

⚙️ JVM Tests - JDK 11 #

📦 extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment

io.quarkus.resteasy.reactive.server.test.multipart.MultipartOptionalInputTest.testUploadWithSomeFilesMissing line 70 - More details - Source on GitHub

java.lang.AssertionError: 
1 expectation failed.
Expected status code <200> but was <500>.

	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
	at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:72)
	at org.codehaus.groovy.reflection.CachedConstructor.doConstructorInvoke(CachedConstructor.java:59)
	at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrap.callConstructor(ConstructorSite.java:84)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:59)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCa...

⚙️ JVM Tests - JDK 11 Windows #

📦 extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment

io.quarkus.resteasy.reactive.server.test.multipart.MultipartOptionalInputTest.testUploadWithSomeFilesMissing line 70 - More details - Source on GitHub

java.lang.AssertionError: 
1 expectation failed.
Expected status code <200> but was <500>.

	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
	at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:72)
	at org.codehaus.groovy.reflection.CachedConstructor.doConstructorInvoke(CachedConstructor.java:59)
	at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrap.callConstructor(ConstructorSite.java:84)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:59)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCa...

⚙️ JVM Tests - JDK 16 #

📦 extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment

io.quarkus.resteasy.reactive.server.test.multipart.MultipartOptionalInputTest.testUploadWithSomeFilesMissing line 70 - More details - Source on GitHub

java.lang.AssertionError: 
1 expectation failed.
Expected status code <200> but was <500>.

	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:78)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
	at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:72)
	at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:105)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:59)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallS...

@geoand
Copy link
Contributor

geoand commented Aug 2, 2021

It seems like you need a different resouce (because MultipartResource expects both xml and txt files to be there)

@andreas-eberle andreas-eberle force-pushed the bugfix/multipart-nullpointer branch from 3edeeaf to dff79b5 Compare August 2, 2021 11:34
@andreas-eberle
Copy link
Contributor Author

Thanks for the hint. Lets see what CI says this time...

@andreas-eberle andreas-eberle force-pushed the bugfix/multipart-nullpointer branch from dff79b5 to c015eb7 Compare August 2, 2021 11:44
@andreas-eberle andreas-eberle force-pushed the bugfix/multipart-nullpointer branch from c015eb7 to 4b3219b Compare August 2, 2021 11:45
@andreas-eberle
Copy link
Contributor Author

@geoand: When I try to run the test in IntelliJ, I get the following exception. Do you have an idea why?

java.lang.NoClassDefFoundError: io/quarkus/gizmo/FieldDescriptor

	at io.quarkus.deployment.configuration.definition.ClassDefinition$LeafMember.<init>(ClassDefinition.java:97)
	at io.quarkus.deployment.configuration.definition.ClassDefinition$ItemMember.<init>(ClassDefinition.java:189)
	at io.quarkus.deployment.configuration.definition.ClassDefinition$ItemMember$Specification.construct(ClassDefinition.java:207)
	at io.quarkus.deployment.configuration.definition.ClassDefinition.<init>(ClassDefinition.java:30)
	at io.quarkus.deployment.configuration.definition.RootDefinition.<init>(RootDefinition.java:27)
	at io.quarkus.deployment.configuration.definition.RootDefinition$Builder.build(RootDefinition.java:119)
	at io.quarkus.deployment.configuration.BuildTimeConfigurationReader.<init>(BuildTimeConfigurationReader.java:105)
	at io.quarkus.deployment.ExtensionLoader.loadStepsFrom(ExtensionLoader.java:142)
	at io.quarkus.deployment.QuarkusAugmentor.run(QuarkusAugmentor.java:104)
	at io.quarkus.runner.bootstrap.AugmentActionImpl.runAugment(AugmentActionImpl.java:413)
	at io.quarkus.runner.bootstrap.AugmentActionImpl.createInitialRuntimeApplication(AugmentActionImpl.java:275)
	at io.quarkus.test.QuarkusUnitTest.beforeAll(QuarkusUnitTest.java:503)
	at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeBeforeAllCallbacks$8(ClassBasedTestDescriptor.java:368)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.invokeBeforeAllCallbacks(ClassBasedTestDescriptor.java:368)
	at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.before(ClassBasedTestDescriptor.java:192)
	at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.before(ClassBasedTestDescriptor.java:78)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:136)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1540)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:143)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:108)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:96)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:75)
	at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:71)
	at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
	at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
	at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)
Caused by: java.lang.ClassNotFoundException: io.quarkus.gizmo.FieldDescriptor
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
	... 49 more

@geoand
Copy link
Contributor

geoand commented Aug 2, 2021

Don't run the Quarkus tests from IntelliJ :). The classpath seems too large for IntelliJ to properly figure out. See https://github.com/quarkusio/quarkus/blob/main/CONTRIBUTING.md#building-a-single-module-of-an-extension for tip for running tests from Maven

@quarkus-bot
Copy link

quarkus-bot bot commented Aug 2, 2021

Failing Jobs - Building 4b3219b

Status Name Step Test failures Logs Raw logs
Gradle Tests - JDK 11 Windows Build ⚠️ Check → Logs Raw logs

@andreas-eberle
Copy link
Contributor Author

@geoand: Do you know why the JDK 11 Windows test failed? On my branch the CI was successful: https://github.com/andreas-eberle/quarkus/runs/3220430247

@geoand
Copy link
Contributor

geoand commented Aug 2, 2021

Those are flaky unfortunately... But since it has nothing to do with this change, it's safe to ignore

@geoand geoand merged commit e9a5368 into quarkusio:main Aug 2, 2021
@quarkus-bot quarkus-bot bot added this to the 2.2 - main milestone Aug 2, 2021
@andreas-eberle
Copy link
Contributor Author

Thanks for the support!

@andreas-eberle andreas-eberle deleted the bugfix/multipart-nullpointer branch August 2, 2021 13:51
@geoand
Copy link
Contributor

geoand commented Aug 2, 2021

Thanks for the fix!

@gsmet gsmet modified the milestones: 2.2 - main, 2.1.1.Final Aug 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants