andymc12 commented on pull request #779:
URL: https://github.com/apache/cxf/pull/779#issuecomment-827062423


   @reta based on my reading of the spec, I think the original behavior is 
correct. (I'll reference Jakarta REST 3.0 spec, since it is publicly available 
- but it should be the same as 2.1, only with different package spaces):
   
   For MBRs, the first thing checked should be the media type, followed by Java 
parameter type, then the `isReadable` method.
   
https://jakarta.ee/specifications/restful-ws/3.0/jakarta-restful-ws-spec-3.0.html#message_body_reader
   
   For MBWs, the first thing checked should be the Java return type, then the 
media type, then the `isWritable` method.
   
https://jakarta.ee/specifications/restful-ws/3.0/jakarta-restful-ws-spec-3.0.html#message_body_writer
   
   Ultimately though, I don't think the order of these operations matters so 
long as there ends up with a sorted list of providers that satisfy all three 
requirements (can convert to/from the same object type, compatible media type, 
and `isReadable` / `isWritable` method returns true).
   
   In Open Liberty, we made a few tweaks to this process that you might want to 
incorporate into your changes:
   (1) We changed the `compareClasses` method slightly so that sub-classes are 
handled correctly: 
   
https://github.com/OpenLiberty/open-liberty/blob/eca9d0bebc1a380e4f78ad1e849735a28aa87754/dev/com.ibm.ws.jaxrs.2.0.common/src/org/apache/cxf/jaxrs/provider/ProviderFactory.java#L1456
   
   (2) We cache the sorted list of MediaTypes for the MBRs/MBWs to avoid 
looking them up and sorting them on each request, ex:
   
https://github.com/OpenLiberty/open-liberty/blob/eca9d0bebc1a380e4f78ad1e849735a28aa87754/dev/com.ibm.ws.org.apache.cxf.cxf.rt.frontend.jaxrs.3.2/src/org/apache/cxf/jaxrs/provider/ProviderFactory.java#L1170
   
   Hope this helps!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to