apache / apache/shenyu

[BUG] Catch-block-only assertion (passes vacuously if no exception)

Open
#6,594 2 comments 0 reactions 1 assignee Claimed by @yykaue View on GitHub
in: test priority: high type: bug
Dominant language
Java
Stars
8.8k
Forks
3.1k
Avg merge
7d 1h
Merged PRs (30d)
85

Description

## Description
`try { sendHeartbeatMethod.invoke(...); } catch (Exception e) { assertTrue(e.getCause() instanceof RuntimeException); }` — no `fail()` after the invoke. If the regression that should make `sendHeartbeat` throw is fixed (or silently starts succeeding), the catch is never entered and the test passes vacuously.

## Location
```
shenyu-register-center/shenyu-register-client-beat/src/test/java/org/apache/shenyu/register/client/beat/HeartbeatListenerTest.java:185-192
```

## Impact
The "login failure -> RuntimeException" contract is unenforced.

## Suggested fix
`assertThrows(InvocationTargetException.class, …)` and assert on cause type.

## Related existing issue(s)
None

_Identified during the 2026-08-02 audit; full list in [`docs/issue-candidates-2026-08-02.md`](docs/issue-candidates-2026-08-02.md)._

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.