cloudevents/sdk-java

JSON content type detection not spec compliant

henning-cg opened this issue · 0 comments

The logic for detecting if the datacontenttype is JSON seems to be contrary to the current spec.

The spec states that:

Such a content type is defined as one having a media subtype equal to json or ending with a +json format extension. That is, a datacontenttype declares JSON-formatted content if its media type, when stripped of parameters, has the form */json or */*+json. If the datacontenttype is unspecified, processing SHOULD proceed as if the datacontenttype had been specified explicitly as application/json

but the code at

return contentType == null || contentType.startsWith("application/json") || contentType.startsWith("text/json");
only checks for empty datacontenttype, application/json or text/json, and is not taking into account for example the extension case "application/something+json"