Skip to content

Commit

Permalink
Java part of MODCLUSTER-298
Browse files Browse the repository at this point in the history
  • Loading branch information
jfclere committed Apr 4, 2012
1 parent 71ca419 commit 874efa2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
Expand Up @@ -31,6 +31,7 @@
import java.io.OutputStreamWriter;
import java.io.Serializable;
import java.io.Writer;
import java.net.Inet6Address;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Socket;
Expand Down Expand Up @@ -810,7 +811,15 @@ void setEstablished(boolean established) {
private synchronized Socket getConnection() throws IOException {
if ((this.socket == null) || this.socket.isClosed()) {
this.socket = this.socketFactory.createSocket();
this.socket.connect(this.socketAddress, this.socketTimeout);
InetAddress address = this.socketAddress.getAddress();
if ( address instanceof Inet6Address && ((Inet6Address)address).isLinkLocalAddress()) {
/* We need to work-around a java6 bug */
InetSocketAddress addr = new InetSocketAddress(address, 0);
this.socket.bind(addr);
this.socket.connect(this.socketAddress, this.socketTimeout);
} else {
this.socket.connect(this.socketAddress, this.socketTimeout);
}
this.socket.setSoTimeout(this.socketTimeout);
this.localAddress = this.socket.getLocalAddress();
}
Expand Down
Expand Up @@ -21,6 +21,8 @@
*/
package org.jboss.modcluster.mcmp.impl;

import java.net.Inet6Address;

import java.util.Collections;
import java.util.Iterator;
import java.util.Map;
Expand Down Expand Up @@ -69,8 +71,21 @@ public MCMPRequest createConfigRequest(Engine engine, NodeConfiguration nodeConf
// so send host name portion, if it exists
String address = connector.getAddress().toString();
int index = address.indexOf("/");
if (connector.getAddress() instanceof Inet6Address) {
/* IPv6 address require a [] */
String saddr = null;
if (index > 0) {
saddr = address.substring(0, index); // Name.
} else {
saddr = "[";
saddr = saddr.concat(address.substring(1));
saddr = saddr.concat("]");
}
parameters.put("Host", saddr);
} else {
parameters.put("Host", (index > 0) ? address.substring(0, index) : address.substring(1));
}

parameters.put("Host", (index > 0) ? address.substring(0, index) : address.substring(1));
parameters.put("Port", String.valueOf(connector.getPort()));
parameters.put("Type", connector.getType().toString());

Expand Down

0 comments on commit 874efa2

Please sign in to comment.