cloudevents / cloudevents/sdk-java
[restful-ws] Allow configuring default writer encoding for CloudEventsProvider
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 446
- Forks
- 172
- PR merge metrics
- No merged PRs in 30d
Description
The CloudEventsProvider defaults to binary encoding. Only when there is an StructuredEncoding annotation present, this mode will be set. See the logic:
This makes the BinaryEncoding useless, confirmed by no usages in the code.
The default to the binary mode is unfortunate. Some implementations like Quarkus RESTEasy Reactive Server Sent Events (SSE) don't provide the annotations. This is problematic, as the binary mode doesn't make sense in SSE - the headers set by CloudEventsProvider are being dropped.
See the code:
See repro: https://github.com/cardil/openshift-knative-showcase/commit/15e00429c459abf655fb483a27f467d598ae173e
Related issue: https://github.com/quarkusio/quarkus/issues/31559
The fact the Quarkus doesn't pass the method annotations, is probably a bug in Quarkus. But, I feel the CloudEvents SDK should allow setting the default mode. Then, the BinaryEncoding could have a meaning, of changing that default encoding per-method.
/kind bug
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in http/restful-ws/src/main/java/io/cloudevents/http/restful/ws/CloudEventsProvider.java, especially the logic around lines 95–112, and review the linked Quarkus SSE behavior. Determine how a configurable default encoding should interact with StructuredEncoding and BinaryEncoding annotations. Done means callers can select the default mode while per-method encoding behavior remains meaningful.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100