Skip to content

Commit

Permalink
CXF-9039: Run Jakarta RESTful Web Services 3.1 TCK. Fixing more test …
Browse files Browse the repository at this point in the history
…failures
  • Loading branch information
reta committed Feb 9, 2025
1 parent acac795 commit 5246612
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@
import org.codehaus.jettison.mapped.TypeConverter;
import org.codehaus.jettison.util.StringIndenter;

@Produces({"application/json", "application/*+json" })
@Consumes({"application/json", "application/*+json" })
@Produces({"application/json", "application/*+json", "text/json" /* deprecated */ })
@Consumes({"application/json", "application/*+json", "text/json"/* deprecated */ })
@Provider
public class JSONProvider<T> extends AbstractJAXBProvider<T> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package org.apache.cxf.jaxrs.provider.jsrjsonb;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
Expand Down Expand Up @@ -83,8 +84,7 @@ public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotat
return isSupportedMediaType(mediaType)
&& !OutputStream.class.isAssignableFrom(type)
&& !Writer.class.isAssignableFrom(type)
&& !CharSequence.class.isAssignableFrom(type)
&& !Response.class.isAssignableFrom(type)
&& !isKnownUnsupportedInOutType(type)
&& !JAXRSUtils.isStreamingLikeOutType(type, genericType);
}

Expand All @@ -98,11 +98,10 @@ public void writeTo(Object t, Class<?> type, Type genericType, Annotation[] anno
@Override
public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
return isSupportedMediaType(mediaType)
&& !Response.class.isAssignableFrom(type)
&& !CharSequence.class.isAssignableFrom(type)
&& !isKnownUnsupportedInOutType(type)
&& !JAXRSUtils.isStreamingLikeOutType(type, genericType);
}

@Override
public Object readFrom(Class<Object> type, Type genericType, Annotation[] annotations, MediaType mediaType,
MultivaluedMap<String, String> httpHeaders, InputStream entityStream)
Expand Down Expand Up @@ -143,4 +142,11 @@ private Jsonb jsonbFor(Class<?> type) {
return DefaultJsonbSupplier.INSTANCE;
}
}

private static boolean isKnownUnsupportedInOutType(Class<?> type) {
return Response.class.isAssignableFrom(type)
|| CharSequence.class.isAssignableFrom(type)
|| File.class.isAssignableFrom(type)
|| byte[].class.isAssignableFrom(type);
}
}

0 comments on commit 5246612

Please sign in to comment.