Commit ac70625
committed
fix(rocketmq): log warning when FLAG or DELAY header is not numeric
RocketMQMessageConverterSupport#getAndWrapMessage swallowed any
Integer.parseInt failure on the MQ_FLAG and DELAY_TIME_LEVEL message
headers with catch (Exception ignored) {}, silently falling back to
flag=0 and delayLevel=0. A producer that set DELAY to a misconfigured
non-numeric value (e.g. via a SpEL expression that produced a String
instead of an int) would have its delayed delivery silently turn into
an immediate send with no log line, no exception, and no way for the
caller to know the header was malformed.
Add an SLF4J logger to the support class and warn with both header
names and their actual values when parsing fails. Behaviour is
otherwise unchanged: flag and delayLevel still fall back to 0, the
broad catch (Exception) is kept, and the DELAY_TIME_LEVEL header lookup
remains inside the try block so any exception path that the original
code happened to absorb is still absorbed. Only the variable
declaration for delayLevelObj is hoisted out of the try block so the
catch clause can include its raw value in the warning.
Adds three regression tests that lock in the fallback behaviour:
non-numeric DELAY_TIME_LEVEL stays at 0, non-numeric FLAG stays at 0,
and conversion does not propagate a parse exception. These tests pass
both before and after the fix; their purpose is to prevent a future
refactor from regressing the silent-fallback semantics that downstream
producers may rely on.1 parent 4877f98 commit ac70625
2 files changed
Lines changed: 52 additions & 2 deletions
File tree
- spring-cloud-alibaba-starters/spring-cloud-starter-stream-rocketmq/src
- main/java/com/alibaba/cloud/stream/binder/rocketmq/support
- test/java/com/alibaba/cloud/stream/binder/rocketmq
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
| 30 | + | |
29 | 31 | | |
30 | 32 | | |
31 | 33 | | |
| |||
40 | 42 | | |
41 | 43 | | |
42 | 44 | | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
43 | 48 | | |
44 | 49 | | |
45 | 50 | | |
| |||
155 | 160 | | |
156 | 161 | | |
157 | 162 | | |
| 163 | + | |
158 | 164 | | |
159 | 165 | | |
160 | | - | |
| 166 | + | |
161 | 167 | | |
162 | 168 | | |
163 | 169 | | |
164 | 170 | | |
165 | 171 | | |
166 | 172 | | |
167 | 173 | | |
168 | | - | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
169 | 180 | | |
170 | 181 | | |
171 | 182 | | |
| |||
Lines changed: 39 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| 28 | + | |
27 | 29 | | |
28 | 30 | | |
29 | 31 | | |
| |||
44 | 46 | | |
45 | 47 | | |
46 | 48 | | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
47 | 86 | | |
0 commit comments