konlue opened a new pull request, #7776:
URL: https://github.com/apache/shenyu/pull/7776
Fixes #7764.
## Summary
`InstanceBeatInfoDTO` carries no identity constraints and
`InstanceCheckService#handleBeatInfo` accepts reports as-is. A beat with a
blank IP reaches `createOrUpdate`, where `selectOneByQuery` omits the IP
predicate for empty values — so an existing valid row can be overwritten with
the blank identity.
## Modifications
- Guard the shared entry point `handleBeatInfo`: a report whose
`instanceIp`, `instancePort`, `instanceType` or `namespaceId` is blank is
dropped with a warn log naming the identity.
- The guard sits in the service (not on the DTO) because
`shenyu-register-protocol` deliberately keeps its wire contract JDK-only, and
because `handleBeatInfo` is the common entry for the controller, WebSocket,
HTTP long polling and internal event paths — one check covers them all.
## Verifying this change
- [x] New
`InstanceCheckServiceTest#testHandleBeatInfoIgnoresIncompleteIdentity`: blank
ip/port/type/namespace and whitespace variants create no live entry, and a
following `syncDB()` issues zero `createOrUpdate` calls. Fails on the current
code (an entry keyed like `:8080@grpc#ns` is created).
- [x] Targeted tests pass:
```bash
./mvnw -B -ntp -pl shenyu-admin test -Dtest=InstanceCheckServiceTest
```
13/13 green.
- [x] Checkstyle passes:
```bash
./mvnw -B -ntp -pl shenyu-admin checkstyle:check
```
clean.
## Notes
With incomplete identities rejected at the entry, the optional-predicate
identity lookup can no longer be hit by a broadened match from this path. The
`/instance/beat` response stays protocol-compatible; returning an explicit
client error for malformed reports can be layered at the controller later if
maintainers prefer. No valid report is affected — all four components are
required identity parts.
--
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]