Added java6 compatibility fix
This commit is contained in:
parent
d78e19ae4c
commit
739315afb4
@ -74,12 +74,22 @@ import java.util.concurrent.TimeUnit;
|
|||||||
public
|
public
|
||||||
class DnsClient {
|
class DnsClient {
|
||||||
|
|
||||||
|
// duplicated in EndPoint
|
||||||
static {
|
static {
|
||||||
|
//noinspection Duplicates
|
||||||
try {
|
try {
|
||||||
// doesn't work in eclipse.
|
// doesn't work when running from inside eclipse.
|
||||||
// Needed for NIO selectors on Android 2.2, and to force IPv4.
|
// Needed for NIO selectors on Android 2.2, and to force IPv4.
|
||||||
System.setProperty("java.net.preferIPv4Stack", Boolean.TRUE.toString());
|
System.setProperty("java.net.preferIPv4Stack", Boolean.TRUE.toString());
|
||||||
System.setProperty("java.net.preferIPv6Addresses", Boolean.FALSE.toString());
|
System.setProperty("java.net.preferIPv6Addresses", Boolean.FALSE.toString());
|
||||||
|
|
||||||
|
// java6 has stack overflow problems when loading certain classes in it's classloader. The result is a StackOverflow when
|
||||||
|
// loading them normally
|
||||||
|
if (OS.javaVersion == 6) {
|
||||||
|
if (PlatformDependent.hasUnsafe()) {
|
||||||
|
PlatformDependent.newFixedMpscQueue(8);
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (AccessControlException ignored) {
|
} catch (AccessControlException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,7 @@ import dorkbox.network.rmi.RmiBridge;
|
|||||||
import dorkbox.network.util.CryptoSerializationManager;
|
import dorkbox.network.util.CryptoSerializationManager;
|
||||||
import dorkbox.network.util.store.NullSettingsStore;
|
import dorkbox.network.util.store.NullSettingsStore;
|
||||||
import dorkbox.network.util.store.SettingsStore;
|
import dorkbox.network.util.store.SettingsStore;
|
||||||
|
import dorkbox.util.OS;
|
||||||
import dorkbox.util.Property;
|
import dorkbox.util.Property;
|
||||||
import dorkbox.util.collections.IntMap;
|
import dorkbox.util.collections.IntMap;
|
||||||
import dorkbox.util.collections.IntMap.Entries;
|
import dorkbox.util.collections.IntMap.Entries;
|
||||||
@ -41,12 +42,14 @@ import io.netty.channel.EventLoopGroup;
|
|||||||
import io.netty.util.NetUtil;
|
import io.netty.util.NetUtil;
|
||||||
import io.netty.util.concurrent.EventExecutor;
|
import io.netty.util.concurrent.EventExecutor;
|
||||||
import io.netty.util.concurrent.Future;
|
import io.netty.util.concurrent.Future;
|
||||||
|
import io.netty.util.internal.PlatformDependent;
|
||||||
import org.bouncycastle.crypto.AsymmetricCipherKeyPair;
|
import org.bouncycastle.crypto.AsymmetricCipherKeyPair;
|
||||||
import org.bouncycastle.crypto.params.ECPrivateKeyParameters;
|
import org.bouncycastle.crypto.params.ECPrivateKeyParameters;
|
||||||
import org.bouncycastle.crypto.params.ECPublicKeyParameters;
|
import org.bouncycastle.crypto.params.ECPublicKeyParameters;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.security.AccessControlException;
|
||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -127,16 +130,27 @@ class EndPoint<C extends Connection> {
|
|||||||
public static int udpMaxSize = 508;
|
public static int udpMaxSize = 508;
|
||||||
|
|
||||||
|
|
||||||
|
// duplicated in DnsClient
|
||||||
static {
|
static {
|
||||||
|
//noinspection Duplicates
|
||||||
try {
|
try {
|
||||||
// doesn't work in eclipse.
|
// doesn't work when running from inside eclipse.
|
||||||
// Needed for NIO selectors on Android 2.2, and to force IPv4.
|
// Needed for NIO selectors on Android 2.2, and to force IPv4.
|
||||||
System.setProperty("java.net.preferIPv4Stack", Boolean.TRUE.toString());
|
System.setProperty("java.net.preferIPv4Stack", Boolean.TRUE.toString());
|
||||||
System.setProperty("java.net.preferIPv6Addresses", Boolean.FALSE.toString());
|
System.setProperty("java.net.preferIPv6Addresses", Boolean.FALSE.toString());
|
||||||
} catch (Throwable ignored) {
|
|
||||||
|
// java6 has stack overflow problems when loading certain classes in it's classloader. The result is a StackOverflow when
|
||||||
|
// loading them normally
|
||||||
|
if (OS.javaVersion == 6) {
|
||||||
|
if (PlatformDependent.hasUnsafe()) {
|
||||||
|
PlatformDependent.newFixedMpscQueue(8);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (AccessControlException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected final org.slf4j.Logger logger;
|
protected final org.slf4j.Logger logger;
|
||||||
|
|
||||||
protected final ThreadGroup threadGroup;
|
protected final ThreadGroup threadGroup;
|
||||||
|
Loading…
Reference in New Issue
Block a user