You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@seata.apache.org by "OmCheeLin (via GitHub)" <gi...@apache.org> on 2025/06/01 14:56:38 UTC

[PR] bugfix: fix port binding [incubator-seata]

OmCheeLin opened a new pull request, #7401:
URL: https://github.com/apache/incubator-seata/pull/7401

   - [ ] I have registered the PR [changes](../changes).
   
   ### Ⅰ. Describe what this PR did
   Resolve potential port conflict issues in `ChannelEventHandlerIntegrationTest.java`
   
   ### Ⅱ. Does this pull request fix one issue?
   
   ### Ⅲ. Why don't you add test cases (unit test/integration test)? 
   
   ### Ⅳ. Describe how to verify it
   
   ### Ⅴ. Special notes for reviews
   
   


-- 
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: fix port binding [incubator-seata]

Posted by "OmCheeLin (via GitHub)" <gi...@apache.org>.
OmCheeLin commented on PR #7401:
URL: https://github.com/apache/incubator-seata/pull/7401#issuecomment-2928115409

   > It would be great to first resolve the issue in this PR, and then gradually improve things by applying this approach step by step.
   > 
   > * [bugfix: Resolve NullPointer and port binding errors #7397](https://github.com/apache/incubator-seata/pull/7397)
   > 
   > I’d appreciate it if you could explain in the issue how this approach addresses the current problem. Also, it would be helpful to include how it handles `flaky tests`, `race conditions`, or cases where a port is already in use.
   
   There is currently an issue with `FileSessionManagerTest.java`, 
   I see that you have solved both `ChannelEventHandlerIntegrationTest.java` and `ChannelEventListenerTest.java`, but I think there may be better ways to modify these two files. You can refer to my file changes.


-- 
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: fix port binding [incubator-seata]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #7401:
URL: https://github.com/apache/incubator-seata/pull/7401#discussion_r2119352298


##########
core/src/test/java/org/apache/seata/core/rpc/netty/ChannelEventHandlerIntegrationTest.java:
##########
@@ -279,4 +283,10 @@ private DefaultChannelGroup collectServerChannels(EventLoopGroup workerGroup) th
         }
         return channels;
     }
+
+    private static int findAvailablePort() throws IOException {
+        try (ServerSocket socket = new ServerSocket(0)) {
+            return socket.getLocalPort();
+        }

Review Comment:
   Using findAvailablePort to obtain a free port may introduce a race condition if the port is claimed between its selection and subsequent binding. Consider holding the ServerSocket open until the test server binds to prevent potential conflicts.
   ```suggestion
       private static ServerSocket findAvailablePort() throws IOException {
           ServerSocket socket = new ServerSocket(0);
           socket.setReuseAddress(true);
           return socket;
   ```



-- 
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: fix port binding [incubator-seata]

Posted by "OmCheeLin (via GitHub)" <gi...@apache.org>.
OmCheeLin closed pull request #7401: bugfix: fix port binding
URL: https://github.com/apache/incubator-seata/pull/7401


-- 
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: fix port binding [incubator-seata]

Posted by "YongGoose (via GitHub)" <gi...@apache.org>.
YongGoose commented on PR #7401:
URL: https://github.com/apache/incubator-seata/pull/7401#issuecomment-2928127896

   > There is currently an issue with `FileSessionManagerTest.java`, I see that you have solved both `ChannelEventHandlerIntegrationTest.java` and `ChannelEventListenerTest.java`, but I think there may be better ways to modify these two files. You can refer to my file changes.
   
   Your approach looks promising!
   
   We’re currently experiencing intermittent `BindExceptions` in our tests.
   If this method can effectively address the issues I mentioned in my previous comment, I think it would be a great idea to refactor all the test cases that currently use statically assigned ports.
   
   That’s why I suggested starting a discussion with the community through an issue — to explore this direction further!
   
   Have a great day :)


-- 
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: fix port binding [incubator-seata]

Posted by "YongGoose (via GitHub)" <gi...@apache.org>.
YongGoose commented on PR #7401:
URL: https://github.com/apache/incubator-seata/pull/7401#issuecomment-2943919819

   > > There is currently an issue with `FileSessionManagerTest.java`, I see that you have solved both `ChannelEventHandlerIntegrationTest.java` and `ChannelEventListenerTest.java`, but I think there may be better ways to modify these two files. You can refer to my file changes.
   > 
   > Your approach looks promising!
   > 
   > We’re currently experiencing intermittent `BindExceptions` in our tests. If this method can effectively address the issues I mentioned in my previous comment, I think it would be a great idea to refactor all the test cases that currently use statically assigned ports.
   > 
   > That’s why I suggested starting a discussion with the community through an issue — to explore this direction further!
   > 
   > Have a great day :)
   
   @OmCheeLin
   
   What do you think?


-- 
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: fix port binding [incubator-seata]

Posted by "OmCheeLin (via GitHub)" <gi...@apache.org>.
OmCheeLin commented on PR #7401:
URL: https://github.com/apache/incubator-seata/pull/7401#issuecomment-2946710837

   @YongGoose 
   You have already solved the problem, that's great. Perhaps we can wait until there are problems in the next test to optimize it.


-- 
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: fix port binding [incubator-seata]

Posted by "YongGoose (via GitHub)" <gi...@apache.org>.
YongGoose commented on PR #7401:
URL: https://github.com/apache/incubator-seata/pull/7401#issuecomment-2928077056

   It would be great to first resolve the issue in this PR, and then gradually improve things by applying this approach step by step.
   - https://github.com/apache/incubator-seata/pull/7397
   
   I’d appreciate it if you could explain in the issue how this approach addresses the current problem.
   Also, it would be helpful to include how it handles `flaky tests`, `race conditions`, or cases where a port is already in use.


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