Skip to content

Commit

Permalink
MODCLUSTER-432 Multicast discovery does not work on Mac OS X, fails w…
Browse files Browse the repository at this point in the history
…ith "Can't assign requested address"

Mirror JGroups behavior
Reenable tests
Include support for Solaris
Rename  the variable to represent better what the property is (was called linuxlike)
Fix redundant and incorrect javadoc
  • Loading branch information
rhusar committed Jul 7, 2015
1 parent a48f09f commit d74dc22
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,20 @@
import org.jboss.modcluster.advertise.MulticastSocketFactory;

/**
* On Linux, we attempt to avoid cross-talk problem by binding the MulticastSocket to the multicast address, if possible. See
* {@linkplain https://jira.jboss.org/jira/browse/JGRP-777}
* On Linux, Solaris and HP-UX, we attempt to avoid cross-talk problem by binding the {@link MulticastSocket} to the
* multicast address, if possible. See <a href="https://jira.jboss.org/jira/browse/JGRP-777">JGRP-777</a>.
*
* @author Paul Ferraro
*/
public class MulticastSocketFactoryImpl implements MulticastSocketFactory {
final Logger log = Logger.getLogger(this.getClass());

private final boolean linuxlike;
private final boolean canBindMulticastSocket;

public MulticastSocketFactoryImpl() {
String value = this.getSystemProperty("os.name");
this.linuxlike = (value != null) && (value.toLowerCase().startsWith("linux") || value.toLowerCase().startsWith("mac") || value.toLowerCase().startsWith("hp"));
this.canBindMulticastSocket = (value != null) && (value.toLowerCase().startsWith("linux") ||
value.toLowerCase().startsWith("sun") || value.toLowerCase().startsWith("hp"));
}

private String getSystemProperty(final String key) {
Expand All @@ -65,13 +66,9 @@ public String run() {
return AccessController.doPrivileged(action);
}

/**
* @{inheritDoc
* @see org.jboss.modcluster.advertise.MulticastSocketFactory#createMulticastSocket(java.net.InetAddress, int)
*/
@Override
public MulticastSocket createMulticastSocket(InetAddress address, int port) throws IOException {
if ((address == null) || !this.linuxlike) return new MulticastSocket(port);
if ((address == null) || !this.canBindMulticastSocket) return new MulticastSocket(port);

if (!address.isMulticastAddress()) {
ModClusterLogger.LOGGER.createMulticastSocketWithUnicastAddress(address);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
import org.jboss.modcluster.mcmp.MCMPHandler;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.mockito.ArgumentCaptor;

Expand Down Expand Up @@ -100,7 +99,6 @@ public void tearDown() {
}

@Test
@Ignore("MODCLUSTER-432")
public void testBasicOperation() throws IOException, NoSuchAlgorithmException {
ArgumentCaptor<InetAddress> capturedAddress = ArgumentCaptor.forClass(InetAddress.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@

import org.jboss.modcluster.advertise.impl.MulticastSocketFactoryImpl;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;

/**
Expand All @@ -51,7 +50,6 @@ public class MulticastSocketFactoryImplTestCase {
private static final int PORT = 23364;

@Test
@Ignore("MODCLUSTER-432")
public void testMulticastSocketNoCrossTalk() throws IOException {
InetAddress address = InetAddress.getByName(GROUP1);

Expand Down

0 comments on commit d74dc22

Please sign in to comment.