Skip to content

Commit 71895d6

Browse files
authored
Merge pull request #566 from rhusar/MODCLUSTER-746
MODCLUSTER-746 Creating an IPv4 multicast socket on Windows while jav…
2 parents 2cf7ced + 8e43ec9 commit 71895d6

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

core/src/main/java/org/jboss/modcluster/ModClusterService.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
*/
2222
package org.jboss.modcluster;
2323

24-
import java.io.IOException;
2524
import java.net.InetAddress;
2625
import java.net.InetSocketAddress;
2726
import java.net.UnknownHostException;
@@ -160,7 +159,7 @@ public synchronized void init(Server server) {
160159
if (Boolean.TRUE.equals(advertise) || (advertise == null && this.mcmpConfig.getProxyConfigurations().isEmpty())) {
161160
try {
162161
this.advertiseListener = this.listenerFactory.createListener(this.mcmpHandler, this.advertiseConfig);
163-
} catch (IOException e) {
162+
} catch (Throwable e) {
164163
ModClusterLogger.LOGGER.advertiseStartFailed(e);
165164
}
166165
}
@@ -194,7 +193,7 @@ public synchronized void shutdown() {
194193
if (this.advertiseListener != null) {
195194
try {
196195
this.advertiseListener.close();
197-
} catch (IOException e) {
196+
} catch (Throwable e) {
198197
ModClusterLogger.LOGGER.catchingDebug(e);
199198
}
200199

core/src/main/java/org/jboss/modcluster/advertise/impl/DatagramChannelFactoryImpl.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,12 @@ public DatagramChannel createDatagramChannel(InetSocketAddress multicastSocketAd
9090
throw ModClusterLogger.LOGGER.createMulticastSocketWithUnicastAddress(address);
9191
}
9292

93+
// Avoid MODCLUSTER-746 Creating an IPv4 multicast socket on Windows while java.net.preferIPv6Addresses=true can throw UnsupportedAddressTypeException
94+
InetSocketAddress bindToPort = (address instanceof Inet4Address) ? new InetSocketAddress("0.0.0.0", port) : new InetSocketAddress("::", port);
95+
9396
// Windows-like
9497
if (!canBindToMulticastAddress) {
95-
return newChannel(address, new InetSocketAddress(port));
98+
return newChannel(address, bindToPort);
9699
}
97100

98101
// Linux-like
@@ -101,7 +104,7 @@ public DatagramChannel createDatagramChannel(InetSocketAddress multicastSocketAd
101104
} catch (IOException e) {
102105
ModClusterLogger.LOGGER.potentialCrossTalking(address, (address instanceof Inet4Address) ? "IPv4" : "IPv6", e.getLocalizedMessage());
103106
ModClusterLogger.LOGGER.catchingDebug(e);
104-
return newChannel(address, new InetSocketAddress(port));
107+
return newChannel(address, bindToPort);
105108
}
106109
}
107110

0 commit comments

Comments
 (0)