Skip to content

Commit d5d9250

Browse files
committed
For #281 fix remote debug issue on jdk13+ with coroutine mode
1 parent e33b523 commit d5d9250

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/java/nginx/clojure/net/NginxClojureSocketFactory.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,21 @@ public SocketImpl createSocketImpl() {
3131
Class<?> socketImpClz = Thread.currentThread().getContextClassLoader().loadClass("java.net.SocksSocketImpl");
3232
@SuppressWarnings("unchecked")
3333
Constructor<SocketImpl> socketConstructor = (Constructor<SocketImpl>) socketImpClz.getDeclaredConstructor();
34-
socketConstructor.setAccessible(true);
34+
socketConstructor.setAccessible(true);
3535
return socketConstructor.newInstance();
36+
} catch (NoSuchMethodException e) { // for jdk13+
37+
Class<?> socketImpClz;
38+
try {
39+
socketImpClz = Thread.currentThread().getContextClassLoader().loadClass("sun.nio.ch.NioSocketImpl");
40+
@SuppressWarnings("unchecked")
41+
Constructor<SocketImpl> socketConstructor = (Constructor<SocketImpl>) socketImpClz.getDeclaredConstructor(Boolean.TYPE);
42+
socketConstructor.setAccessible(true);
43+
return socketConstructor.newInstance(false);
44+
} catch (InvocationTargetException ex) {
45+
throw new RuntimeException(ex.getCause());
46+
} catch (Throwable ex) {
47+
throw new RuntimeException(ex);
48+
}
3649
} catch (InvocationTargetException e) {
3750
throw new RuntimeException(e.getCause());
3851
} catch (Throwable e) {

0 commit comments

Comments
 (0)