spring.cloud.stream.function.autodetect=true (default setting) for spring-webflux app with server.forward-headers-strategy=FRAMEWORK can't work
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Anfängerfreundlichkeit
- 25/100
- Issue-Typ
- Bug
- Klarheit
- Muss geklärt werden
- Aktivitätsstatus
- Veraltet
- Tech-Stack
- java, spring, spring-boot
- Bereich
- backend, distributed-systems
Rechercherichtung
Es werden keine Quelldateien oder Tests genannt. Beginne damit, den Fall in Spring WebFlux mit server.forward-headers-strategy=FRAMEWORK und aktivierter Option spring.cloud.stream.function.autodetect nachzustellen, und verfolge dann, wie ForwardedHeaderTransformer in die Erkennung funktionaler Beans und das Binding gelangt. Als abgeschlossen gilt die Arbeit, wenn die beschriebenen Szenarien mit ausschließlich Output und mit einem einzelnen funktionalen Bean keinen unbeabsichtigten Consumer mehr erzeugen und die Autodetektion nicht mehr fehlschlägt, während das beabsichtigte Nullkonfigurationsverhalten weiterhin definiert bleibt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Describe the issue
Using a spring-webflux app with server.forward-headers-strategy=FRAMEWORK, autoconfiguration provides a ForwardedHeaderTransformer bean which breaks all use cases of spring.cloud.stream.function.autodetect :
- if you have only output-bindings, a queue is createded and a consumer is registered on this queue which noone ever wants. If you send a message to this queue, you get
java.lang.ClassCastException: class [B cannot be cast to class org.springframework.http.server.reactive.ServerHttpRequest ([B is in module java.base of loader 'bootstrap'; org.springframework.http.server.reactive.ServerHttpRequest is in unnamed module of loader 'app')
- if you had a single java.util.function.* bean and relied on autodetection, it doesn't work.:
17:59:09.253 [main] WARN org.springframework.cloud.function.context.catalog.BeanFactoryAwareFunctionRegistry - Multiple functional beans were found [forwardedHeaderTransformer, myConsumer], thus can't determine default function definition. Please use 'spring.cloud.function.definition' property to explicitly define it.
To Reproduce
Steps to reproduce the behavior:
see above
all versions
Additional context
In the docs there is the following note:
In the event you only have single bean of type java.util.function.[Supplier/Function/Consumer], you can skip the spring.cloud.function.definition property, since such functional bean will be auto-discovered. However, it is considered best practice to use such property to avoid any confusion. Some time this auto-discovery can get in the way, since single bean of type java.util.function.[Supplier/Function/Consumer] could be there for purposes other then handling messages, yet being single it is auto-discovered and auto-bound. For these rare scenarios you can disable auto-discovery by providing spring.cloud.stream.function.autodetect property with value set to false.
To me, this would have been a good idea if there were really no easy cases where autodection breaks down. It depends on what "rare" means of course, but just a plain webflux springboot app with a single nonexotic property "server.forward-headers-strategy" doesn't seem to be that rare.
So maybe just make autodetection opt-in ? But then it doesn't make much sense, autodetection is for zero config (onboarding), so it's not interesting to add explicit autodetection=true configuration just to avoid some other configuration..
So maybe just delete autodetection entirely? You would lose the easy zero config onboarding.
Or make the autodection really reliable:
- maybe the autodetection should only happen when there is zero spring.cloud.stream.bindings or output-bindings configuration ? zeroconfig onboarding would still work (unless the user chose webflux+forward-headers-strategy=FRAMEWORK to try it out) and normal applications with only output-bindings wouldn't get the spurious consumer
- maybe find a way to exclude all "standard" beans. Based on the package ? Based on the function Signature (who would use Function<HttpServletRequest, HttpServletRequest>) ? Based on something else ?
- another idea ?
Cheers,
Jon
- Vorherrschende Sprache
- Java
- Sterne
- 1.1k
- Forks
- 657
- Ø Merge
- 1 T. 18 Std.
- Gemergte PRs (30 T.)
- 8
Entwicklungsumgebung
Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus spring-cloud/spring-cloud-stream
-
Move the spring-cloud-commons version and BOM import from the bus parent to the stream parentEvtl. vergeben @olegz hat das heute übernommen. Offentask
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
spring-cloud/spring-cloud-stream#3355 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Kafka binder skips failed input records when DLQ publication failsEvtl. vergeben @itsgourav62 hat das vor 2 Tagen übernommen. Offenbug
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 55/100
spring-cloud/spring-cloud-stream#3350 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Clarify support for manual ack/nack with batch mode + DLQ; potential bug in acknowledge(index) pathOffen
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 48/100
spring-cloud/spring-cloud-stream#3189 · 3 Kommentare · 1 Reaktion ·
Maintainer antworten meist innerhalb von 1 Tag
-
Add RecordInterceptor support for Kafka Streams binderEvtl. wieder frei Ein Pull Request dazu wurde ohne Merge geschlossen. Offenenhancement
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 35/100
spring-cloud/spring-cloud-stream#3188 · 4 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
task
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 48/100
spring-cloud/spring-cloud-stream#3187 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in spring-cloud/spring-cloud-stream
Ähnliche Issues
-
Add contributing guideEvtl. vergeben @WadekarPrashant hat das heute übernommen. Offengood first issue
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 88/100
jenkinsci/gitea-checks-plugin#382 · 1 Kommentar ·
-
enhancement infra
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 67/100
Maintainer antworten meist innerhalb von 1 Tag
-
5.0.x backport bug
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 68/100
spring-cloud/spring-cloud-function#1569 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug untriaged
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
opensearch-project/opensearch-java#2342 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Netcracker/qubership-integration-platform#1417 ·
Maintainer antworten meist innerhalb von 1 Tag