From 6169df2bc5af8c65d29aba7ab8f932eaba3d38f7 Mon Sep 17 00:00:00 2001 From: jim-krueger Date: Fri, 13 Oct 2023 09:03:25 -0500 Subject: [PATCH] Fix multipart example with addition of GenericEntity --- .../main/java/jaxrs/examples/multipart/MultipartClient.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/src/main/java/jaxrs/examples/multipart/MultipartClient.java b/examples/src/main/java/jaxrs/examples/multipart/MultipartClient.java index 602b5d16e..65fa2d527 100644 --- a/examples/src/main/java/jaxrs/examples/multipart/MultipartClient.java +++ b/examples/src/main/java/jaxrs/examples/multipart/MultipartClient.java @@ -1,5 +1,5 @@ /******************************************************************* -* Copyright (c) 2021 Eclipse Foundation +* Copyright (c) 2021, 2023 Eclipse Foundation * * This specification document is made available under the terms * of the Eclipse Foundation Specification License v1.0, which is @@ -22,6 +22,7 @@ import jakarta.ws.rs.client.Entity; import jakarta.ws.rs.client.WebTarget; import jakarta.ws.rs.core.EntityPart; +import jakarta.ws.rs.core.GenericEntity; import jakarta.ws.rs.core.GenericType; import jakarta.ws.rs.core.MediaType; import jakarta.ws.rs.core.Response; @@ -34,7 +35,7 @@ public boolean sendPdfs(Path dir) throws IOException { List parts = Files.list(dir).map(this::toPart).collect(Collectors.toList()); Client client = ClientBuilder.newClient(); WebTarget target = client.target("http://localhost:9080/multipart?dirName=abc"); - Entity> entity = Entity.entity(parts, MediaType.MULTIPART_FORM_DATA); + Entity>> entity = Entity.entity(new GenericEntity<>(parts) { }, MediaType.MULTIPART_FORM_DATA); Response response = target.request().post(entity); return response.getStatus() == 200; }