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

NullPointerException when no file is pass to to rest client reactive #20606

Closed
KienDangTran opened this issue Oct 8, 2021 · 1 comment · Fixed by #20597
Closed

NullPointerException when no file is pass to to rest client reactive #20606

KienDangTran opened this issue Oct 8, 2021 · 1 comment · Fixed by #20597
Labels
area/rest-client kind/bug Something isn't working
Milestone

Comments

@KienDangTran
Copy link

KienDangTran commented Oct 8, 2021

Describe the bug

When using rest client reactive with multipart formdata, if I don't pass any file then a NPE will occur

java.lang.NullPointerException: Cannot invoke "java.io.File.toPath()" because "<parameter1>.files" is null

the request object model look like this

public class AppointmentFormData {

	@RestForm
	@PartType(MediaType.TEXT_PLAIN)
	public String documents;

	@RestForm("files")
	@PartType(MediaType.APPLICATION_OCTET_STREAM)
	public File files;

}

end the rest client

@Path("/appointments")
@RegisterRestClient(configKey = "appointment-service")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public interface V1AppointmentServiceRestClient {
	@GET
	@Path("/{id}")
	Uni<V1Appointment> getAppointmentById(@PathParam("id") Long id);

	@POST
	@Consumes(MediaType.MULTIPART_FORM_DATA)
	Uni<V1Appointment> createAppointment(@MultipartForm AppointmentFormData data);
}

Expected behavior

if there is no file, it should still send data successfully

Actual behavior

throw NPE

How to Reproduce?

No response

Output of uname -a or ver

Darwin 20.6.0 Darwin Kernel Version 20.6.0: Wed Jun 23 00:26:31 PDT 2021; root:xnu-7195.141.2~5/RELEASE_X86_64 x86_64

Output of java -version

openjdk version "16.0.1" 2021-04-20 OpenJDK Runtime Environment AdoptOpenJDK-16.0.1+9 (build 16.0.1+9) OpenJDK 64-Bit Server VM AdoptOpenJDK-16.0.1+9 (build 16.0.1+9, mixed mode, sharing)

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.3.0.final

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.8.1 (05c21c65bdfed0f71a2f2ada8b84da59348c4c5d)

Additional information

No response

@KienDangTran KienDangTran added the kind/bug Something isn't working label Oct 8, 2021
@quarkus-bot
Copy link

quarkus-bot bot commented Oct 8, 2021

/cc @michalszynkiewicz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/rest-client kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant