pyshiweijia opened a new issue, #8169:
URL: https://github.com/apache/incubator-seata/issues/8169

   ### Check Ahead
   
   - [x] I have searched the [issues](https://github.com/seata/seata/issues) of 
this repository and believe that this is not a duplicate.
   
   - [x] I am willing to try to fix this bug myself.
   
   
   ### Ⅰ. Issue Description
   
   `NetUtil.getIgnoredInterfacesLocalAddress(String[], String...)` returns the 
global `LOCAL_ADDRESS` immediately when it has already been initialized. As a 
result, `ignoredInterfaces` and `preferredNetworks` are not evaluated when an 
earlier call has populated the default local-address cache. The global cache 
predates the ignored-interface support added in #8090.
   
   ### Ⅱ. Describe what happened
   
   After a default lookup caches a local address, a lookup that ignores every 
interface still returns the cached address.
   
   ```java
   @Test
   public void testIgnoredInterfacesAreAppliedAfterDefaultAddressIsCached() {
       assertThat(NetUtil.getLocalAddress()).isNotNull();
       assertThat(NetUtil.getIgnoredInterfacesLocalAddress(new String[] 
{".*"})).isNull();
   }
   ```
   
   ```text
   expected: null
    but was: /192.168.124.25
   ```
   
   The same early return also bypasses `preferredNetworks`.
   
   ### Ⅲ. Describe what you expected to happen
   
   Parameterized lookups should evaluate the supplied interface filters and 
preferred-network rules regardless of whether an unfiltered address was 
previously cached. The unfiltered no-argument lookup may continue to use the 
global cache.
   
   ### Ⅳ. How to reproduce it (as minimally and precisely as possible)
   
   1. Checkout the `2.x` branch.
   2. Add the test above to `NetUtilTest`.
   3. Run `mvn -pl common -am test 
"-Dtest=NetUtilTest#testIgnoredInterfacesAreAppliedAfterDefaultAddressIsCached" 
"-Dsurefire.failIfNoSpecifiedTests=false" "-Dlicense.skip=true" -B`.
   
   The test fails because `getIgnoredInterfacesLocalAddress` returns before 
calling `getLocalAddress0`.
   
   ### Ⅴ. Anything else we need to know?
   
   Suggested direction: keep caching only for semantically unfiltered lookups. 
Calls with non-empty `ignoredInterfaces` or `preferredNetworks` should resolve 
using their parameters without reading or overwriting the default cache. A 
cache keyed by normalized parameters is another option.
   
   Impact is conditional: server startup is unaffected when the configured 
lookup is the first local-address query. Existing tests only assert non-null 
results and do not verify that the supplied rules affect selection.
   
   ### Ⅵ. Environment
   
   - Branch: `2.x`
   - Revision: `e6d0860a4345b10cb59c65c78215ec51d67f59d1`
   - JDK: Oracle JDK 17.0.14; targeted regression also passes after the fix on 
JDK 8u202
   - Maven: 3.8.4
   - OS: Windows 11 amd64


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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to