Disable SCTP tests on platforms that not support them, also not run tests for sctp OIO. See #633
This commit is contained in:
parent
6143626427
commit
e9d2ebea3d
@ -35,8 +35,10 @@ import io.netty.channel.socket.oio.OioServerSocketChannel;
|
||||
import io.netty.channel.socket.oio.OioSctpServerChannel;
|
||||
import io.netty.channel.socket.oio.OioSocketChannel;
|
||||
import io.netty.channel.socket.oio.OioSctpChannel;
|
||||
import io.netty.testsuite.util.TestUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
@ -239,8 +241,11 @@ final class SocketTestPermutation {
|
||||
}
|
||||
|
||||
static List<Factory<ServerBootstrap>> sctpServerChannel() {
|
||||
List<Factory<ServerBootstrap>> list = new ArrayList<Factory<ServerBootstrap>>();
|
||||
if (!TestUtils.isSctpSupported()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
List<Factory<ServerBootstrap>> list = new ArrayList<Factory<ServerBootstrap>>();
|
||||
// Make the list of ServerBootstrap factories.
|
||||
list.add(new Factory<ServerBootstrap>() {
|
||||
@Override
|
||||
@ -250,6 +255,8 @@ final class SocketTestPermutation {
|
||||
channel(NioSctpServerChannel.class);
|
||||
}
|
||||
});
|
||||
/*
|
||||
* Comment out till #632 is fixes
|
||||
list.add(new Factory<ServerBootstrap>() {
|
||||
@Override
|
||||
public ServerBootstrap newInstance() {
|
||||
@ -258,11 +265,16 @@ final class SocketTestPermutation {
|
||||
channel(OioSctpServerChannel.class);
|
||||
}
|
||||
});
|
||||
*/
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
static List<Factory<Bootstrap>> sctpClientChannel() {
|
||||
if (!TestUtils.isSctpSupported()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
List<Factory<Bootstrap>> list = new ArrayList<Factory<Bootstrap>>();
|
||||
list.add(new Factory<Bootstrap>() {
|
||||
@Override
|
||||
@ -270,12 +282,15 @@ final class SocketTestPermutation {
|
||||
return new Bootstrap().group(new NioEventLoopGroup()).channel(NioSctpChannel.class);
|
||||
}
|
||||
});
|
||||
list.add(new Factory<Bootstrap>() {
|
||||
/*
|
||||
* Comment out till #632 is fixes
|
||||
* list.add(new Factory<Bootstrap>() {
|
||||
@Override
|
||||
public Bootstrap newInstance() {
|
||||
return new Bootstrap().group(new OioEventLoopGroup()).channel(OioSctpChannel.class);
|
||||
}
|
||||
});
|
||||
*/
|
||||
return list;
|
||||
}
|
||||
|
||||
|
@ -1,84 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012 The Netty Project
|
||||
*
|
||||
* The Netty Project licenses this file to you under the Apache License,
|
||||
* version 2.0 (the "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package io.netty.channel.socket.aio;
|
||||
|
||||
import java.lang.invoke.MethodHandle;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class MethodHandleAioChannelFinder implements AioChannelFinder {
|
||||
private static volatile Map<Class<?>, MethodHandle> handleCache = new HashMap<Class<?>, MethodHandle>();
|
||||
|
||||
@Override
|
||||
public AbstractAioChannel findChannel(Runnable command) throws Exception {
|
||||
MethodHandle handle;
|
||||
for (;;) {
|
||||
handle = findHandle(command);
|
||||
if (handle == null) {
|
||||
return null;
|
||||
}
|
||||
Object next;
|
||||
try {
|
||||
next = handle.invokeExact();
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
throw new Exception("Unable to invoke handle " + handle, e);
|
||||
}
|
||||
if (next instanceof AbstractAioChannel) {
|
||||
return (AbstractAioChannel) next;
|
||||
}
|
||||
command = (Runnable) next;
|
||||
}
|
||||
}
|
||||
|
||||
private static MethodHandle findHandle(Object command) throws Exception {
|
||||
Map<Class<?>, MethodHandle> handleCache = MethodHandleAioChannelFinder.handleCache;
|
||||
Class<?> commandType = command.getClass();
|
||||
MethodHandle res = handleCache.get(commandType);
|
||||
if (res != null) {
|
||||
return res;
|
||||
}
|
||||
|
||||
for (Field f: commandType.getDeclaredFields()) {
|
||||
if (f.getType() == Runnable.class) {
|
||||
return put(handleCache, commandType, f);
|
||||
}
|
||||
|
||||
// Check against the actual class as this is what will be used by the jdk
|
||||
// if you use a final variable and pass it to a Runnable
|
||||
if (f.getType().isAssignableFrom(AbstractAioChannel.class)
|
||||
|| f.getType() == Object.class) {
|
||||
f.setAccessible(true);
|
||||
Object candidate = f.get(command);
|
||||
if (candidate instanceof AbstractAioChannel) {
|
||||
return put(handleCache, commandType, f);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static MethodHandle put(Map<Class<?>, MethodHandle> oldCache, Class<?> key, Field value) throws Exception {
|
||||
MethodHandle handle = MethodHandles.lookup().findGetter(key, value.getName(), value.getType());
|
||||
Map<Class<?>, MethodHandle> newCache = new HashMap<Class<?>, MethodHandle>(oldCache.size());
|
||||
newCache.putAll(oldCache);
|
||||
newCache.put(key, handle);
|
||||
handleCache = newCache;
|
||||
return handle;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user