Copilot commented on code in PR #6386:
URL: https://github.com/apache/shenyu/pull/6386#discussion_r3418004893
##########
shenyu-common/src/main/java/org/apache/shenyu/common/constant/Constants.java:
##########
@@ -713,6 +713,11 @@ public interface Constants {
*/
String X_ACCESS_TOKEN = "X-Access-Token";
+ /**
+ * X-Shenyu-Sync-Token.
+ */
+ String SHENYU_WEBSOCKET_SYNC_TOKEN = "X-Shenyu-Sync-Token";
+
Review Comment:
Constant naming in `Constants` is inconsistent with the other HTTP header
constants nearby (`X_ACCESS_TOKEN`, `X_API_KEY`). Since this value represents
an `X-*` header, consider renaming `SHENYU_WEBSOCKET_SYNC_TOKEN` to an
`X_...`-prefixed constant (e.g., `X_SHENYU_SYNC_TOKEN`) and updating all usages
to match, to keep the constants API predictable.
##########
shenyu-sync-data-center/shenyu-sync-data-websocket/src/test/java/org/apache/shenyu/plugin/sync/data/websocket/config/WebsocketConfigTest.java:
##########
@@ -64,13 +70,14 @@ public void testEquals() {
@Test
public void testHashCode() {
- assertEquals(Objects.hash(websocketConfig.getUrls(),
websocketConfig.getAllowOrigin()), websocketConfig.hashCode());
+ assertEquals(Objects.hash(websocketConfig.getUrls(),
websocketConfig.getAllowOrigin(), websocketConfig.getToken()),
websocketConfig.hashCode());
}
@Test
public void testToString() {
- String toString = "WebsocketConfig{urls='%s, allowOrigin='%s}";
+ String toString = "WebsocketConfig{urls='%s, allowOrigin='%s,
token='******}";
Review Comment:
`testToString` currently asserts against a malformed `toString()` format
(missing closing quotes). If `WebsocketConfig.toString()` is corrected to
include proper quoting, this expected string should be updated accordingly
while still asserting the real token value is not leaked.
##########
shenyu-sync-data-center/shenyu-sync-data-websocket/src/main/java/org/apache/shenyu/plugin/sync/data/websocket/config/WebsocketConfig.java:
##########
@@ -92,6 +114,7 @@ public String toString() {
+ urls
+ ", allowOrigin='"
Review Comment:
`WebsocketConfig.toString()` builds an invalid/ambiguous string (missing
closing quotes around `urls`/`allowOrigin`, and `token` is missing the closing
quote before `}`), which makes logs/debug output harder to read even though the
token is masked.
--
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]