TheR1sing3un commented on code in PR #6068:
URL: https://github.com/apache/rocketmq/pull/6068#discussion_r1108771653
##########
test/src/test/java/org/apache/rocketmq/test/autoswitchrole/AutoSwitchRoleBase.java:
##########
@@ -69,28 +69,28 @@ protected static void initialize() {
}
}
- public static Integer nextPort() throws IOException {
+ public static int nextPort() throws IOException {
return nextPort(1001, 9999);
}
- public static Integer nextPort(Integer minPort, Integer maxPort) throws
IOException {
+ public static int nextPort(int minPort, int maxPort) throws IOException {
+
Random random = new Random();
int tempPort;
int port;
- try {
- while (true) {
+ while (true) {
+ try {
tempPort = random.nextInt(maxPort) % (maxPort - minPort + 1) +
minPort;
ServerSocket serverSocket = new ServerSocket(tempPort);
port = serverSocket.getLocalPort();
serverSocket.close();
break;
+ } catch (IOException ignored) {
+ if (number > 200) {
Review Comment:
How about merge `numer>200` and `number++` ? Just `if (number++ >200)`
--
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]