Skip to content

Commit 2687de0

Browse files
committed
Add HandshakeWebSocketService runtime hints
Closes gh-29146
1 parent 241261b commit 2687de0

File tree

3 files changed

+40
-1
lines changed

3 files changed

+40
-1
lines changed

spring-webflux/src/main/java/org/springframework/web/reactive/socket/server/support/HandshakeWebSocketService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public HandshakeWebSocketService(RequestUpgradeStrategy upgradeStrategy) {
114114
this.upgradeStrategy = upgradeStrategy;
115115
}
116116

117-
private static RequestUpgradeStrategy initUpgradeStrategy() {
117+
static RequestUpgradeStrategy initUpgradeStrategy() {
118118
String className;
119119
if (tomcatPresent) {
120120
className = "TomcatRequestUpgradeStrategy";
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright 2002-2022 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.web.reactive.socket.server.support;
18+
19+
import org.springframework.aot.hint.MemberCategory;
20+
import org.springframework.aot.hint.RuntimeHints;
21+
import org.springframework.aot.hint.RuntimeHintsRegistrar;
22+
23+
/**
24+
* {@link RuntimeHintsRegistrar} implementation that registers reflection hints related to
25+
* {@link HandshakeWebSocketService}.
26+
*
27+
* @author Sebastien Deleuze
28+
* @since 6.0
29+
*/
30+
class HandshakeWebSocketServiceRuntimeHints implements RuntimeHintsRegistrar {
31+
32+
@Override
33+
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
34+
hints.reflection().registerType(HandshakeWebSocketService.initUpgradeStrategy().getClass(),
35+
MemberCategory.INVOKE_DECLARED_CONSTRUCTORS);
36+
}
37+
}

spring-webflux/src/main/java/org/springframework/web/reactive/socket/server/support/WebSocketHandlerAdapter.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import reactor.core.publisher.Mono;
2020

21+
import org.springframework.context.annotation.ImportRuntimeHints;
2122
import org.springframework.core.Ordered;
2223
import org.springframework.util.Assert;
2324
import org.springframework.web.reactive.HandlerAdapter;
@@ -45,6 +46,7 @@
4546
* @author Rossen Stoyanchev
4647
* @since 5.0
4748
*/
49+
@ImportRuntimeHints(HandshakeWebSocketServiceRuntimeHints.class)
4850
public class WebSocketHandlerAdapter implements HandlerAdapter, Ordered {
4951

5052
private final WebSocketService webSocketService;

0 commit comments

Comments
 (0)