btlqql opened a new pull request, #4288:
URL: https://github.com/apache/rocketmq-dashboard/pull/4288
## What is the purpose of the change
`MessagePropertyDisplay.limitProperties` caps every message property value at
`MAX_PROPERTY_VALUE_CHARS` (1024) and marks the cut with `...`. The cap
counts UTF-16 chars, but the
text it cuts is not ASCII-only, and `abbreviate` used a plain `substring(0,
1024)`. Whenever the
limit lands between the two chars of a supplementary character the returned
value ends with an
unpaired high surrogate. A `char` is not a code point, so the JSON body
carries an invalid
`\uD83D` escape and the message detail panel shows a replacement glyph at
the end of an already
abbreviated value.
The repository already treats this as a defect elsewhere, which is what
makes the raw cut an
oversight rather than a deliberate limit: `CredentialUtils.mask` cuts on a
code point boundary
because it "prevents a supplementary character from being split into an
isolated surrogate in API
responses", and the web-side truncation of these same message properties was
fixed in #4226. The
server helper that feeds both panels kept the raw `substring`.
`abbreviate` now backs off one char when the char at the cap starts a pair,
so the result never
contains an isolated surrogate, while a pair that fits inside the cap is
still kept in full. Values
within the cap, the `...` marker, `MAX_PROPERTIES` and
`hasOversizedProperty` are unchanged, so the
"this value was abbreviated" hint stays consistent with what is rendered.
## Brief changelog
- `MessagePropertyDisplay.abbreviate`: do not cut inside a surrogate pair —
back off one char when
the char at the cap is a high surrogate.
- `MessagePropertyDisplayTest`: two new cases — the cap falling inside a
pair (1023 ASCII chars +
an emoji) and a pair that fits inside the cap (1022 ASCII chars + an
emoji); both assert that the
result contains no unpaired surrogate.
## Verification
Red first, on the unmodified implementation with only the new tests added:
```
mvn -f server/pom.xml -B -Dtest=MessagePropertyDisplayTest
-DfailIfNoTests=false test
[ERROR] Tests run: 7, Failures: 1, Errors: 0, Skipped: 0, Time elapsed:
0.086 s <<< FAILURE! -- in
org.apache.rocketmq.studio.common.util.MessagePropertyDisplayTest
[ERROR]
org.apache.rocketmq.studio.common.util.MessagePropertyDisplayTest.limitPropertiesShouldNotSplitASurrogatePairTest
-- Time elapsed: 0.012 s <<< FAILURE!
org.opentest4j.AssertionFailedError:
Expecting value to be false but was true
at
...MessagePropertyDisplayTest.limitPropertiesShouldNotSplitASurrogatePairTest(MessagePropertyDisplayTest.java:66)
[INFO] BUILD FAILURE
```
`:66` is `assertThat(hasUnpairedSurrogate(abbreviated)).isFalse()`: the
returned value is 1023 ASCII
chars followed by `U+D83D` — the high surrogate of the emoji — and then
`...`.
Green after the change:
```
[INFO] Tests run: 7, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.071
s -- in org.apache.rocketmq.studio.common.util.MessagePropertyDisplayTest
[INFO] BUILD SUCCESS
```
Whole backend suite on this branch (`mvn -f server/pom.xml -B test`):
`Tests run: 2153, Failures: 5, Errors: 5, Skipped: 0`. The five failures and
five errors are the same
ten test ids that fail on the unmodified base `6c24d2ed` (`Tests run: 2151,
Failures: 5, Errors: 5`):
eight need a POSIX `sh` CLI that this Windows machine does not have
(`CliAgentProviderTest`,
`ClaudeCodeAgentProviderTest`) and two are
`AuthCorsIntegrationTest.shouldRejectNonAdminMutationBeforeControllerExecution`
/
`shouldStillRejectAnonymousProtectedRequests`, which are aligned separately
in #4217. No other test
moved.
Closes #4287
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]