From 818a78d82cd9aeb6c7429ef97cd1f39f9053b909 Mon Sep 17 00:00:00 2001 From: Max Romanov Date: Mon, 27 Dec 2021 16:37:36 +0300 Subject: Java: fixing multiple SCI initializations. - Ignoring Tomcat WebSocket container initialization. - Renaming application class loader to UnitClassLoader to avoid development environment enablement in Spring Boot. This closes #609 issue on GitHub. --- src/java/nginx/unit/Context.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'src/java') diff --git a/src/java/nginx/unit/Context.java b/src/java/nginx/unit/Context.java index 0197858b..e1245e1f 100644 --- a/src/java/nginx/unit/Context.java +++ b/src/java/nginx/unit/Context.java @@ -422,7 +422,7 @@ public class Context implements ServletContext, InitParams processWebXml(root); - loader_ = new AppClassLoader(urls, + loader_ = new UnitClassLoader(urls, Context.class.getClassLoader().getParent()); Class wsSession_class = WsSession.class; @@ -531,7 +531,7 @@ public class Context implements ServletContext, InitParams } } - private static class AppClassLoader extends URLClassLoader + private static class UnitClassLoader extends URLClassLoader { static { ClassLoader.registerAsParallelCapable(); @@ -547,7 +547,7 @@ public class Context implements ServletContext, InitParams private ClassLoader system_loader; - public AppClassLoader(URL[] urls, ClassLoader parent) + public UnitClassLoader(URL[] urls, ClassLoader parent) { super(urls, parent); @@ -1514,6 +1514,18 @@ public class Context implements ServletContext, InitParams { trace("loadInitializer: initializer: " + sci.getClass().getName()); + /* + Unit WebSocket container is a copy of Tomcat WsSci with own + transport implementation. Tomcat implementation will not work in + Unit and should be ignored here. + */ + if (sci.getClass().getName() + .equals("org.apache.tomcat.websocket.server.WsSci")) + { + trace("loadInitializer: ignore"); + return; + } + HandlesTypes ann = sci.getClass().getAnnotation(HandlesTypes.class); if (ann == null) { trace("loadInitializer: no HandlesTypes annotation"); @@ -1558,7 +1570,6 @@ public class Context implements ServletContext, InitParams try { sci.onStartup(handles_classes, this); - metadata_complete_ = true; } catch(Exception e) { System.err.println("loadInitializer: exception caught: " + e.toString()); } -- cgit From a3d19f71a205d31ce141dcfd8880f7ed13bd65e5 Mon Sep 17 00:00:00 2001 From: Alejandro Colomar Date: Sun, 19 Dec 2021 00:58:18 +0100 Subject: Fixed indentation. Some lines (incorrectly) had an indentation of 3 or 5, or 7 or 9, or 11 or 13, or 15 or 17 spaces instead of 4, 8, 12, or 16. Fix them. Found with: $ find src -type f | xargs grep -n '^ [^ ]'; $ find src -type f | xargs grep -n '^ [^ *]'; $ find src -type f | xargs grep -n '^ [^ ]'; $ find src -type f | xargs grep -n '^ [^ *]'; $ find src -type f | xargs grep -n '^ [^ +]'; $ find src -type f | xargs grep -n '^ [^ *+]'; $ find src -type f | xargs grep -n '^ [^ +]'; $ find src -type f | xargs grep -n '^ [^ *+]'; --- src/java/nginx/unit/websocket/WsRemoteEndpointImplBase.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/java') diff --git a/src/java/nginx/unit/websocket/WsRemoteEndpointImplBase.java b/src/java/nginx/unit/websocket/WsRemoteEndpointImplBase.java index 776124fd..d451db7d 100644 --- a/src/java/nginx/unit/websocket/WsRemoteEndpointImplBase.java +++ b/src/java/nginx/unit/websocket/WsRemoteEndpointImplBase.java @@ -1175,7 +1175,7 @@ public abstract class WsRemoteEndpointImplBase implements RemoteEndpoint { } else if (state == State.WRITER_WRITING) { // NO-OP. Leave state as is. } else if (state == State.STREAM_WRITING) { - // NO-OP. Leave state as is. + // NO-OP. Leave state as is. } else { // Should never happen // The if ... else ... blocks above should cover all states -- cgit