Skip to content

Commit b6ab7a6

Browse files
committed
Checking if port is availaible otherwise not starting
1 parent 6a0eb1b commit b6ab7a6

2 files changed

Lines changed: 2 additions & 3 deletions

File tree

  • src
    • main/java/io/github/intisy/utils/custom/external
    • test/java/io/github/intisy/utils/custom/external

src/main/java/io/github/intisy/utils/custom/external/Redis.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ private int findFreePort() {
7979
}
8080

8181
public void connect() throws IOException {
82-
if (useEmbedded) {
82+
if (useEmbedded && isPortAvailable(port) && isPortAvailable(port + 1)) {
8383
try {
8484
startEmbeddedServer();
8585
} catch (IOException e) {

src/test/java/io/github/intisy/utils/custom/external/TestRedis.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ private static void testWithEmbeddedRedis() {
2828

2929
try {
3030
System.out.println("Attempting to connect to embedded Redis server...");
31-
if (redis.isPortAvailable(redis.getPort()))
32-
redis.connect();
31+
redis.connect();
3332

3433
if (redis.isConnected()) {
3534
System.out.println("Embedded Redis server is running");

0 commit comments

Comments
 (0)