AbstractMethodError with barchart-udt
Motivation: `SocketChannelUDT` from barchart-udt does not have the java 7 `public abstract SocketChannel bind(SocketAddress local)` method. Calling the abstract method `SocketChannel.bind(SocketAddress localAddress)` for `SocketChannelUDT` leads to an `AbstractMethodError` runtime error. Modifications: Make workaround with explicit call of `SocketChannelUDT.bind(SocketAddress local)` as it done in `NioUdtByteConnectorChannel`. Result: Fixes [#6934].
This commit is contained in:
parent
91b62da8c1
commit
1ba265ad4d
@ -31,8 +31,12 @@ import io.netty.channel.udt.UdtMessage;
|
||||
import io.netty.util.internal.logging.InternalLogger;
|
||||
import io.netty.util.internal.logging.InternalLoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.SocketAddress;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedActionException;
|
||||
import java.security.PrivilegedExceptionAction;
|
||||
import java.util.List;
|
||||
|
||||
import static java.nio.channels.SelectionKey.*;
|
||||
@ -98,7 +102,7 @@ public class NioUdtMessageConnectorChannel extends AbstractNioMessageChannel imp
|
||||
|
||||
@Override
|
||||
protected void doBind(final SocketAddress localAddress) throws Exception {
|
||||
SocketUtils.bind(javaChannel(), localAddress);
|
||||
privilegedBind(javaChannel(), localAddress);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -233,4 +237,19 @@ public class NioUdtMessageConnectorChannel extends AbstractNioMessageChannel imp
|
||||
public InetSocketAddress remoteAddress() {
|
||||
return (InetSocketAddress) super.remoteAddress();
|
||||
}
|
||||
|
||||
private static void privilegedBind(final SocketChannelUDT socketChannel, final SocketAddress localAddress)
|
||||
throws IOException {
|
||||
try {
|
||||
AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() {
|
||||
@Override
|
||||
public Void run() throws IOException {
|
||||
socketChannel.bind(localAddress);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
} catch (PrivilegedActionException e) {
|
||||
throw (IOException) e.getCause();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user