Skip to content

Commit 7af9ce4

Browse files
committed
Add resource hint for spring.properties
Fixes gh-31270
1 parent 4c343ef commit 7af9ce4

File tree

3 files changed

+88
-1
lines changed

3 files changed

+88
-1
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright 2002-2023 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.aot.hint.support;
18+
19+
import org.springframework.aot.hint.RuntimeHints;
20+
import org.springframework.aot.hint.RuntimeHintsRegistrar;
21+
22+
/**
23+
* {@link RuntimeHintsRegistrar} to register hints for {@link org.springframework.core.SpringProperties}.
24+
*
25+
* @author Brian Clozel
26+
* @since 6.1
27+
*/
28+
class SpringPropertiesRuntimeHints implements RuntimeHintsRegistrar {
29+
30+
@Override
31+
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
32+
hints.resources().registerPattern("spring.properties");
33+
}
34+
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
org.springframework.aot.hint.RuntimeHintsRegistrar=\
22
org.springframework.aot.hint.support.KotlinDetectorRuntimeHints,\
33
org.springframework.aot.hint.support.ObjectToObjectConverterRuntimeHints,\
4-
org.springframework.aot.hint.support.SpringFactoriesLoaderRuntimeHints
4+
org.springframework.aot.hint.support.SpringFactoriesLoaderRuntimeHints,\
5+
org.springframework.aot.hint.support.SpringPropertiesRuntimeHints
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Copyright 2002-2023 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.aot.hint.support;
18+
19+
20+
import org.junit.jupiter.api.BeforeEach;
21+
import org.junit.jupiter.api.Test;
22+
23+
import org.springframework.aot.hint.RuntimeHints;
24+
import org.springframework.aot.hint.RuntimeHintsRegistrar;
25+
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
26+
import org.springframework.core.io.support.SpringFactoriesLoader;
27+
import org.springframework.util.ClassUtils;
28+
29+
import static org.assertj.core.api.Assertions.assertThat;
30+
31+
/**
32+
* Tests for {@link SpringPropertiesRuntimeHints}.
33+
* @author Brian Clozel
34+
*/
35+
class SpringPropertiesRuntimeHintsTests {
36+
37+
private RuntimeHints hints;
38+
39+
@BeforeEach
40+
void setup() {
41+
this.hints = new RuntimeHints();
42+
SpringFactoriesLoader.forResourceLocation("META-INF/spring/aot.factories")
43+
.load(RuntimeHintsRegistrar.class).forEach(registrar -> registrar
44+
.registerHints(this.hints, ClassUtils.getDefaultClassLoader()));
45+
}
46+
47+
@Test
48+
void springPropertiesResourceHasHints() {
49+
assertThat(RuntimeHintsPredicates.resource().forResource("spring.properties")).accepts(this.hints);
50+
}
51+
52+
}

0 commit comments

Comments
 (0)