Skip to content

Commit c15f45d

Browse files
Only register hints for servlet applications
Closes gh-12622
1 parent 3572111 commit c15f45d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

test/src/main/java/org/springframework/security/test/aot/hint/WebTestUtilsTestRuntimeHints.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,6 +23,7 @@
2323
import org.springframework.security.web.context.SecurityContextPersistenceFilter;
2424
import org.springframework.security.web.csrf.CsrfFilter;
2525
import org.springframework.test.context.aot.TestRuntimeHintsRegistrar;
26+
import org.springframework.util.ClassUtils;
2627

2728
/**
2829
* {@link TestRuntimeHintsRegistrar} implementation that register runtime hints for
@@ -35,6 +36,9 @@ class WebTestUtilsTestRuntimeHints implements TestRuntimeHintsRegistrar {
3536

3637
@Override
3738
public void registerHints(RuntimeHints hints, Class<?> testClass, ClassLoader classLoader) {
39+
if (!ClassUtils.isPresent("jakarta.servlet.Filter", classLoader)) {
40+
return;
41+
}
3842
registerFilterChainProxyHints(hints);
3943
registerSecurityContextRepositoryHints(hints);
4044
registerCsrfTokenRepositoryHints(hints);

0 commit comments

Comments
 (0)