cloudevents / cloudevents/sdk-java

[restful-ws] Allow configuring default writer encoding for CloudEventsProvider

Offen
#533 4 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

enhancement
Vorherrschende Sprache
Java
Sterne
446
Forks
172
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

The CloudEventsProvider defaults to binary encoding. Only when there is an StructuredEncoding annotation present, this mode will be set. See the logic:

https://github.com/cloudevents/sdk-java/blob/3614a4f5f4982e6ed38332c2cc73b1a558326274/http/restful-ws/src/main/java/io/cloudevents/http/restful/ws/CloudEventsProvider.java#L95-L112

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:

https://github.com/quarkusio/quarkus/blob/247736226a8c8a55fa88a662eda05963803905eb/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/SseUtil.java#L141-L142

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne in http/restful-ws/src/main/java/io/cloudevents/http/restful/ws/CloudEventsProvider.java, insbesondere mit der Logik rund um die Zeilen 95–112, und überprüfe das verknüpfte Quarkus-SSE-Verhalten. Ermittle, wie eine konfigurierbare Standardkodierung mit den Annotationen StructuredEncoding und BinaryEncoding interagieren sollte. Die Aufgabe ist erledigt, wenn Aufrufer den Standardmodus auswählen können und das Kodierungsverhalten pro Methode weiterhin sinnvoll bleibt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
java
Bereich
api
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
45/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.