From 4fbca99f202bfbc932d6d0eaff025e750c4833c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deleuze?= Date: Thu, 5 Dec 2024 15:44:09 +0100 Subject: [PATCH] Remove unnecessary HandshakeHandlerRuntimeHints Those hints are not needed anymore as of Spring Framework 6.1. Backport of gh-34032. Closes gh-34033 --- .../support/HandshakeHandlerRuntimeHints.java | 93 ------------------- .../resources/META-INF/spring/aot.factories | 2 - 2 files changed, 95 deletions(-) delete mode 100644 spring-websocket/src/main/java/org/springframework/web/socket/server/support/HandshakeHandlerRuntimeHints.java delete mode 100644 spring-websocket/src/main/resources/META-INF/spring/aot.factories diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/server/support/HandshakeHandlerRuntimeHints.java b/spring-websocket/src/main/java/org/springframework/web/socket/server/support/HandshakeHandlerRuntimeHints.java deleted file mode 100644 index 46a513377f7..00000000000 --- a/spring-websocket/src/main/java/org/springframework/web/socket/server/support/HandshakeHandlerRuntimeHints.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright 2002-2024 the original author or authors. - * - * Licensed 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 - * - * https://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 org.springframework.web.socket.server.support; - -import org.springframework.aot.hint.MemberCategory; -import org.springframework.aot.hint.ReflectionHints; -import org.springframework.aot.hint.RuntimeHints; -import org.springframework.aot.hint.RuntimeHintsRegistrar; -import org.springframework.aot.hint.TypeReference; -import org.springframework.lang.Nullable; -import org.springframework.util.ClassUtils; - -/** - * {@link RuntimeHintsRegistrar} implementation that registers reflection hints - * for {@link AbstractHandshakeHandler}. - * - * @author Sebastien Deleuze - * @since 6.0 - */ -class HandshakeHandlerRuntimeHints implements RuntimeHintsRegistrar { - - private static final boolean tomcatWsPresent; - - private static final boolean jettyWsPresent; - - private static final boolean undertowWsPresent; - - private static final boolean glassfishWsPresent; - - private static final boolean weblogicWsPresent; - - private static final boolean websphereWsPresent; - - static { - ClassLoader classLoader = AbstractHandshakeHandler.class.getClassLoader(); - tomcatWsPresent = ClassUtils.isPresent( - "org.apache.tomcat.websocket.server.WsHttpUpgradeHandler", classLoader); - jettyWsPresent = ClassUtils.isPresent( - "org.eclipse.jetty.ee10.websocket.server.JettyWebSocketServerContainer", classLoader); - undertowWsPresent = ClassUtils.isPresent( - "io.undertow.websockets.jsr.ServerWebSocketContainer", classLoader); - glassfishWsPresent = ClassUtils.isPresent( - "org.glassfish.tyrus.servlet.TyrusHttpUpgradeHandler", classLoader); - weblogicWsPresent = ClassUtils.isPresent( - "weblogic.websocket.tyrus.TyrusServletWriter", classLoader); - websphereWsPresent = ClassUtils.isPresent( - "com.ibm.websphere.wsoc.WsWsocServerContainer", classLoader); - } - - - @Override - public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader) { - ReflectionHints reflectionHints = hints.reflection(); - if (tomcatWsPresent) { - registerType(reflectionHints, "org.springframework.web.socket.server.standard.TomcatRequestUpgradeStrategy"); - } - else if (jettyWsPresent) { - registerType(reflectionHints, "org.springframework.web.socket.server.jetty.JettyRequestUpgradeStrategy"); - } - else if (undertowWsPresent) { - registerType(reflectionHints, "org.springframework.web.socket.server.standard.UndertowRequestUpgradeStrategy"); - } - else if (glassfishWsPresent) { - registerType(reflectionHints, "org.springframework.web.socket.server.standard.GlassFishRequestUpgradeStrategy"); - } - else if (weblogicWsPresent) { - registerType(reflectionHints, "org.springframework.web.socket.server.standard.WebLogicRequestUpgradeStrategy"); - } - else if (websphereWsPresent) { - registerType(reflectionHints, "org.springframework.web.socket.server.standard.WebSphereRequestUpgradeStrategy"); - } - } - - private void registerType(ReflectionHints reflectionHints, String className) { - reflectionHints.registerType(TypeReference.of(className), - builder -> builder.withMembers(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS)); - } - -} diff --git a/spring-websocket/src/main/resources/META-INF/spring/aot.factories b/spring-websocket/src/main/resources/META-INF/spring/aot.factories deleted file mode 100644 index e33a7e934f1..00000000000 --- a/spring-websocket/src/main/resources/META-INF/spring/aot.factories +++ /dev/null @@ -1,2 +0,0 @@ -org.springframework.aot.hint.RuntimeHintsRegistrar= \ -org.springframework.web.socket.server.support.HandshakeHandlerRuntimeHints \ No newline at end of file