use of io.netty.util.internal.SuppressJava6Requirement in project netty by netty.
the class NioDatagramChannel method leaveGroup.
@SuppressJava6Requirement(reason = "Usage guarded by java version check")
@Override
public ChannelFuture leaveGroup(InetAddress multicastAddress, NetworkInterface networkInterface, InetAddress source, ChannelPromise promise) {
checkJavaVersion();
ObjectUtil.checkNotNull(multicastAddress, "multicastAddress");
ObjectUtil.checkNotNull(networkInterface, "networkInterface");
synchronized (this) {
if (memberships != null) {
List<MembershipKey> keys = memberships.get(multicastAddress);
if (keys != null) {
Iterator<MembershipKey> keyIt = keys.iterator();
while (keyIt.hasNext()) {
MembershipKey key = keyIt.next();
if (networkInterface.equals(key.networkInterface())) {
if (source == null && key.sourceAddress() == null || source != null && source.equals(key.sourceAddress())) {
key.drop();
keyIt.remove();
}
}
}
if (keys.isEmpty()) {
memberships.remove(multicastAddress);
}
}
}
}
promise.setSuccess();
return promise;
}
use of io.netty.util.internal.SuppressJava6Requirement in project netty by netty.
the class NioDatagramChannel method block.
/**
* Block the given sourceToBlock address for the given multicastAddress on the given networkInterface
*/
@SuppressJava6Requirement(reason = "Usage guarded by java version check")
@Override
public ChannelFuture block(InetAddress multicastAddress, NetworkInterface networkInterface, InetAddress sourceToBlock, ChannelPromise promise) {
checkJavaVersion();
ObjectUtil.checkNotNull(multicastAddress, "multicastAddress");
ObjectUtil.checkNotNull(sourceToBlock, "sourceToBlock");
ObjectUtil.checkNotNull(networkInterface, "networkInterface");
synchronized (this) {
if (memberships != null) {
List<MembershipKey> keys = memberships.get(multicastAddress);
for (MembershipKey key : keys) {
if (networkInterface.equals(key.networkInterface())) {
try {
key.block(sourceToBlock);
} catch (IOException e) {
promise.setFailure(e);
}
}
}
}
}
promise.setSuccess();
return promise;
}
use of io.netty.util.internal.SuppressJava6Requirement in project netty by netty.
the class ReferenceCountedOpenSslEngine method getSSLParameters.
@SuppressJava6Requirement(reason = "Usage guarded by java version check")
@Override
public final synchronized SSLParameters getSSLParameters() {
SSLParameters sslParameters = super.getSSLParameters();
int version = PlatformDependent.javaVersion();
if (version >= 7) {
sslParameters.setEndpointIdentificationAlgorithm(endPointIdentificationAlgorithm);
Java7SslParametersUtils.setAlgorithmConstraints(sslParameters, algorithmConstraints);
if (version >= 8) {
if (sniHostNames != null) {
Java8SslUtils.setSniHostNames(sslParameters, sniHostNames);
}
if (!isDestroyed()) {
Java8SslUtils.setUseCipherSuitesOrder(sslParameters, (SSL.getOptions(ssl) & SSL.SSL_OP_CIPHER_SERVER_PREFERENCE) != 0);
}
Java8SslUtils.setSNIMatchers(sslParameters, matchers);
}
}
return sslParameters;
}
use of io.netty.util.internal.SuppressJava6Requirement in project netty by netty.
the class DatagramUnicastIPv6Test method assumeIpv6Supported.
@SuppressJava6Requirement(reason = "Guarded by java version check")
@BeforeAll
public static void assumeIpv6Supported() {
try {
if (PlatformDependent.javaVersion() < 7) {
throw new UnsupportedOperationException();
}
Channel channel = SelectorProvider.provider().openDatagramChannel(StandardProtocolFamily.INET6);
channel.close();
} catch (UnsupportedOperationException e) {
throw new AssumptionViolatedException("IPv6 not supported", e);
} catch (IOException ignore) {
// Ignore
}
}
use of io.netty.util.internal.SuppressJava6Requirement in project netty by netty.
the class ByteBufIndexOfBenchmark method init.
@Setup(Level.Trial)
@SuppressJava6Requirement(reason = "using SplittableRandom to reliably produce data")
public void init() {
System.setProperty("io.netty.noUnsafe", Boolean.valueOf(noUnsafe).toString());
SplittableRandom random = new SplittableRandom(seed);
permutations = 1 << logPermutations;
this.data = new ByteBuf[permutations];
final ByteBufAllocator allocator = pooled ? PooledByteBufAllocator.DEFAULT : UnpooledByteBufAllocator.DEFAULT;
for (int i = 0; i < permutations; ++i) {
data[i] = direct ? allocator.directBuffer(size, size) : allocator.heapBuffer(size, size);
for (int j = 0; j < size; j++) {
int value = random.nextInt(Byte.MIN_VALUE, Byte.MAX_VALUE + 1);
// turn any found value into something different
if (value == needleByte) {
if (needleByte != 1) {
value = 1;
} else {
value = 0;
}
}
data[i].setByte(j, value);
}
final int foundIndex = random.nextInt(Math.max(0, size - 8), size);
data[i].setByte(foundIndex, needleByte);
}
}
Aggregations