This is an automated email from the ASF dual-hosted git repository.

reta pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cxf.git


The following commit(s) were added to refs/heads/main by this push:
     new 8896c46df2 CXF-9178: Run Jakarta RESTful Web Services 4.0 TCK
8896c46df2 is described below

commit 8896c46df2b22969968d6ca380ee291e07071334
Author: Andriy Redko <[email protected]>
AuthorDate: Tue Jan 27 21:34:22 2026 -0500

    CXF-9178: Run Jakarta RESTful Web Services 4.0 TCK
---
 .../main/java/org/apache/cxf/jaxrs/impl/EntityPartImpl.java    | 10 ++++++++++
 .../java/org/apache/cxf/jaxrs/provider/EntityPartProvider.java |  4 ++--
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git 
a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/EntityPartImpl.java 
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/EntityPartImpl.java
index 0c1a68a3f6..bce0850ce0 100644
--- 
a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/EntityPartImpl.java
+++ 
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/EntityPartImpl.java
@@ -30,6 +30,7 @@ import java.nio.file.Files;
 import java.nio.file.Path;
 import java.util.Objects;
 import java.util.Optional;
+import java.util.concurrent.atomic.AtomicBoolean;
 
 import jakarta.ws.rs.WebApplicationException;
 import jakarta.ws.rs.core.EntityPart;
@@ -49,6 +50,7 @@ public class EntityPartImpl implements EntityPart {
     private final GenericType<?> genericType;
     private final Class<?> type;
     private final Providers providers;
+    private final AtomicBoolean consumed = new AtomicBoolean();
 
     //CHECKSTYLE:OFF
     public EntityPartImpl(Providers providers, String name, String fileName, 
Object content, Class<?> type,
@@ -124,6 +126,10 @@ public class EntityPartImpl implements EntityPart {
     public <T> T getContent(Class<T> asType) throws IllegalArgumentException, 
IllegalStateException,
             IOException, WebApplicationException {
 
+        if (consumed.compareAndExchange(false, true)) {
+            throw new IllegalStateException("Content has been consumed 
already");
+        }
+
         if (asType == null) {
             throw new NullPointerException("The type is required");
         }
@@ -152,6 +158,10 @@ public class EntityPartImpl implements EntityPart {
     public <T> T getContent(GenericType<T> asType) throws 
IllegalArgumentException, IllegalStateException,
             IOException, WebApplicationException {
 
+        if (consumed.compareAndExchange(false, true)) {
+            throw new IllegalStateException("Content has been consumed 
already");
+        }
+
         if (asType == null) {
             throw new NullPointerException("The generic type is required");
         }
diff --git 
a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/EntityPartProvider.java
 
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/EntityPartProvider.java
index 3a962b08dd..f38a8a449a 100644
--- 
a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/EntityPartProvider.java
+++ 
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/EntityPartProvider.java
@@ -164,10 +164,10 @@ public class EntityPartProvider extends 
AbstractConfigurableProvider
             final String name = StringUtils.isEmpty(cdName) ? contentId : 
cdName.replace("\"", "").replace("'", "");
 
             if (!StringUtils.isEmpty(fileName)) {
-                return new EntityPartImpl(providers, name, fileName, is, c, 
genericType, headers,
+                return new EntityPartImpl(mc.getProviders(), name, fileName, 
is, c, genericType, headers,
                     attachment.getContentType());
             } else {
-                return new EntityPartImpl(providers, name, null, is, c, 
genericType, headers,
+                return new EntityPartImpl(mc.getProviders(), name, null, is, 
c, genericType, headers,
                     attachment.getContentType());
             }
         } else {

Reply via email to