Commit dad9879
GH-3242: Key StreamBridge function cache by binding name
StreamBridge caches the FunctionInvocationWrapper used by send(..) under the
producer properties. The binding name only took part in that key when
partitionKeyExpression and ProducerProperties#getBindingName() were both set,
and getBindingName() is never populated on the instance StreamBridge reads:
BindingService#bindProducer populates it on the extended copy it creates for an
ExtendedPropertiesBinder, not on the original returned by
BindingServiceProperties#getProducerProperties.
A partitioned binding therefore shared its cached function with another binding,
and since the partition enhancer is left on the cached function after a send
that produced a partition header, the next send on the other binding failed with
IllegalArgumentException: Partition key cannot be null.
Take the binding name from the send(..) argument, which is always available, and
include it for partitioned bindings. Key the cache by a record of the five
properties rather than by their computed int hash, so bindings are told apart by
equality and no hash collision can make two of them share a function. Bindings
that are not partitioned keep sharing a cached function as before.
Signed-off-by: kdelay <kdelay20@gmail.com>
Resolves #32441 parent 2f88288 commit dad9879
2 files changed
Lines changed: 94 additions & 17 deletions
File tree
- core
- spring-cloud-stream-integration-tests/src/test/java/org/springframework/cloud/stream/function
- spring-cloud-stream/src/main/java/org/springframework/cloud/stream/function
Lines changed: 73 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
| 51 | + | |
50 | 52 | | |
51 | 53 | | |
52 | 54 | | |
| |||
487 | 489 | | |
488 | 490 | | |
489 | 491 | | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
490 | 553 | | |
491 | 554 | | |
492 | 555 | | |
| |||
933 | 996 | | |
934 | 997 | | |
935 | 998 | | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
936 | 1009 | | |
937 | 1010 | | |
938 | 1011 | | |
| |||
core/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/function/StreamBridge.java
Lines changed: 21 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
120 | | - | |
| 120 | + | |
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
| |||
197 | 197 | | |
198 | 198 | | |
199 | 199 | | |
200 | | - | |
| 200 | + | |
201 | 201 | | |
202 | 202 | | |
203 | 203 | | |
| |||
233 | 233 | | |
234 | 234 | | |
235 | 235 | | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | | - | |
250 | | - | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
251 | 242 | | |
252 | 243 | | |
253 | 244 | | |
| |||
394 | 385 | | |
395 | 386 | | |
396 | 387 | | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
397 | 401 | | |
398 | 402 | | |
399 | 403 | | |
| |||
0 commit comments