You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@seata.apache.org by "angus-guo (via GitHub)" <gi...@apache.org> on 2026/08/13 16:37:30 UTC
[PR] bugfix: apply ignoredInterfaces and preferredNetworks when the default address is cached [incubator-seata]
angus-guo opened a new pull request, #8202:
URL: https://github.com/apache/incubator-seata/pull/8202
## Issue
`getIgnoredInterfacesLocalAddress(String[], String...)` returns the global `LOCAL_ADDRESS` immediately when it has already been initialized, regardless of the supplied `ignoredInterfaces` or `preferredNetworks` patterns. Once an unfiltered lookup (through `getLocalAddress()` or `getLocalIp()`) has populated the cache, a subsequent filtered lookup is answered from that cache without evaluating its patterns.
**Symptom:** After `Server.start()` made registry settings reachable from `application.yml` in #8187, the filters configured in YAML are read successfully but then silently ignored here.
This was discovered in #8169:
```java
@Test
public void testIgnoredInterfacesAreAppliedAfterDefaultAddressIsCached() {
assertThat(NetUtil.getLocalAddress()).isNotNull();
assertThat(NetUtil.getIgnoredInterfacesLocalAddress(new String[] {".*"})).isNull();
}
```
```text
expected: null
but was: /192.168.124.25
```
## Change
Keep caching only for semantically unfiltered lookups. A call with non-empty `ignoredInterfaces` or `preferredNetworks` resolves through `getLocalAddress0(...)` without reading or overwriting the default cache:
```java
if (CollectionUtils.isEmpty(ignoredInterfaces) && CollectionUtils.isEmpty(preferredNetworks)) {
if (LOCAL_ADDRESS != null) {
return LOCAL_ADDRESS;
}
InetAddress localAddress = getLocalAddress0(ignoredInterfaces, preferredNetworks);
LOCAL_ADDRESS = localAddress;
return localAddress;
}
return getLocalAddress0(ignoredInterfaces, preferredNetworks);
```
`getLocalAddress()` and `getLocalIp()` (no arguments → both `null`) remain cached. `Server.start()` performs its filtered lookup once at startup, so no hot path loses caching.
The global cache predates the ignored-interface support added in #8090, and the early return was never conditioned on whether the supplied parameters matched the cached call's parameters.
## Tests
Three new cases in `NetUtilTest`:
- **`testIgnoredInterfacesAreAppliedAfterDefaultAddressIsCached`** — the pattern `.*` matches every interface, so the result is `null` rather than the cached address. **Fails before this change.**
- **`testPreferredNetworksAreAppliedAfterDefaultAddressIsCached`** — the same early return bypassed `preferredNetworks`. Ignoring every interface through the preferred-network path also yields no candidate, so the result is `null`. **Fails before this change.**
- **`testUnfilteredLookupRemainsCached`** — the unfiltered lookup keeps returning the same cached instance (no regression).
Both failing tests demonstrate the bug from #8169 and confirm the fix. Existing tests in the same file only assert non-null results and do not verify that the supplied rules affect selection, which is why the bug was not caught earlier.
Verified:
- All 33 tests in `NetUtilTest` pass.
- All 693 tests in the `common` module pass.
- `spotless:check` and `checkstyle:check` pass on the `common` module.
## Checklist
- [x] **Check Ahead**
- [x] I have searched the [issues](https://github.com/apache/incubator-seata/issues) of this repository and believe that this is not a duplicate.
- [x] I am willing to try to fix this bug myself.
- [ ] I have added the change log of the current PR to [changes/en-us/2.x.md](https://github.com/apache/incubator-seata/blob/2.x/changes/en-us/2.x.md) and [changes/zh-cn/2.x.md](https://github.com/apache/incubator-seata/blob/2.x/changes/zh-cn/2.x.md). *(Will add once the PR number is assigned.)*
- [x] I have passed all the tests locally.
- [x] I have added the unit test for my change.
--
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: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [PR] bugfix: apply ignoredInterfaces and preferredNetworks when the default address is cached [incubator-seata]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #8202:
URL: https://github.com/apache/incubator-seata/pull/8202#issuecomment-5283774931
## [Codecov](https://app.codecov.io/gh/apache/incubator-seata/pull/8202?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:x: Patch coverage is `85.71429%` with `1 line` in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 73.25%. Comparing base ([`7075121`](https://app.codecov.io/gh/apache/incubator-seata/commit/707512178662d8801a41b1781618a9447769667e?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`58f273d`](https://app.codecov.io/gh/apache/incubator-seata/commit/58f273d49a7e3b48da69415106e129a8861703cc?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
:warning: Report is 2 commits behind head on 2.x.
| [Files with missing lines](https://app.codecov.io/gh/apache/incubator-seata/pull/8202?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
|---|---|---|
| [...ain/java/org/apache/seata/common/util/NetUtil.java](https://app.codecov.io/gh/apache/incubator-seata/pull/8202?src=pr&el=tree&filepath=common%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fseata%2Fcommon%2Futil%2FNetUtil.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Y29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zZWF0YS9jb21tb24vdXRpbC9OZXRVdGlsLmphdmE=) | 85.71% | [0 Missing and 1 partial :warning: ](https://app.codecov.io/gh/apache/incubator-seata/pull/8202?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## 2.x #8202 +/- ##
============================================
+ Coverage 73.18% 73.25% +0.07%
- Complexity 1141 1142 +1
============================================
Files 1152 1153 +1
Lines 42356 42342 -14
Branches 5059 5059
============================================
+ Hits 30998 31019 +21
+ Misses 8875 8838 -37
- Partials 2483 2485 +2
```
| [Files with missing lines](https://app.codecov.io/gh/apache/incubator-seata/pull/8202?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [...ain/java/org/apache/seata/common/util/NetUtil.java](https://app.codecov.io/gh/apache/incubator-seata/pull/8202?src=pr&el=tree&filepath=common%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fseata%2Fcommon%2Futil%2FNetUtil.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Y29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zZWF0YS9jb21tb24vdXRpbC9OZXRVdGlsLmphdmE=) | `66.66% <85.71%> (+3.41%)` | :arrow_up: |
... and [36 files with indirect coverage changes](https://app.codecov.io/gh/apache/incubator-seata/pull/8202/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
[](https://app.codecov.io/gh/apache/incubator-seata/pull/8202?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
</details>
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
--
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: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [PR] bugfix: apply ignoredInterfaces and preferredNetworks when the default address is cached [incubator-seata]
Posted by "angus-guo (via GitHub)" <gi...@apache.org>.
angus-guo commented on PR #8202:
URL: https://github.com/apache/incubator-seata/pull/8202#issuecomment-5447040883
Closing this as it duplicates #8191, which was merged on Aug 15. Both PRs fixed the same bug (filtered lookups bypassing the cached default address) with the same implementation and similar test coverage.
Thanks for catching this independently — good to see the same issue being spotted from different angles.
--
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: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [PR] bugfix: apply ignoredInterfaces and preferredNetworks when the default address is cached [incubator-seata]
Posted by "angus-guo (via GitHub)" <gi...@apache.org>.
angus-guo closed pull request #8202: bugfix: apply ignoredInterfaces and preferredNetworks when the default address is cached
URL: https://github.com/apache/incubator-seata/pull/8202
--
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: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org