apache / apache/shenyu

[BUG] Real outbound HTTPS to www.baidu.com in unit test

Open Beginner friendly
#6,589 1 comment 0 reactions 0 assignees 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
`when(upstream.getUrl()).thenReturn("https://www.baidu.com"); healthCheckTask.run();` opens a real outbound TLS connection to a public site. The comment even admits it ("Even if the address could not connect, it will return false"). Fails on any CI without internet egress or when baidu is slow.

## Location
```
shenyu-loadbalancer/src/test/java/org/apache/shenyu/loadbalancer/cache/UpstreamCheckTaskTest.java:90
```

## Impact
Environment-dependent false failures; test asserts behavior the comment says is unreliable.

## Suggested fix
`mockStatic(UpstreamCheckUtils.class)` to return canned results, or point at a `WireMock`/`HttpServer` started on `new ServerSocket(0)`.

## 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

Research direction

Open shenyu-loadbalancer/src/test/java/org/apache/shenyu/loadbalancer/cache/UpstreamCheckTaskTest.java around line 90 and run the test to reproduce its outbound request. Trace the healthCheckTask.run() setup and choose the suggested static mock or local server approach. Done means the test makes no public HTTPS connection and remains deterministic in offline CI.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
testing
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.