Skip to content

Commit

Permalink
Only register hints for servlet applications
Browse files Browse the repository at this point in the history
Closes gh-12622
  • Loading branch information
marcusdacoregio committed Feb 3, 2023
1 parent 3572111 commit c15f45d
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 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.
Expand All @@ -23,6 +23,7 @@
import org.springframework.security.web.context.SecurityContextPersistenceFilter;
import org.springframework.security.web.csrf.CsrfFilter;
import org.springframework.test.context.aot.TestRuntimeHintsRegistrar;
import org.springframework.util.ClassUtils;

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

@Override
public void registerHints(RuntimeHints hints, Class<?> testClass, ClassLoader classLoader) {
if (!ClassUtils.isPresent("jakarta.servlet.Filter", classLoader)) {
return;
}
registerFilterChainProxyHints(hints);
registerSecurityContextRepositoryHints(hints);
registerCsrfTokenRepositoryHints(hints);
Expand Down

0 comments on commit c15f45d

Please sign in to comment.