Skip to content

Commit 730b049

Browse files
committed
Mark ApplicationInfoPropertySource as immutable
Update `ApplicationInfoPropertySource` to indicate it is immutable and is safe to have mappings cached. Closes gh-44856
1 parent 1257f81 commit 730b049

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ApplicationInfoPropertySource.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2024 the original author or authors.
2+
* Copyright 2012-2025 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.
@@ -19,6 +19,8 @@
1919
import java.util.HashMap;
2020
import java.util.Map;
2121

22+
import org.springframework.boot.origin.Origin;
23+
import org.springframework.boot.origin.OriginLookup;
2224
import org.springframework.boot.system.ApplicationPid;
2325
import org.springframework.core.env.ConfigurableEnvironment;
2426
import org.springframework.core.env.MapPropertySource;
@@ -32,7 +34,7 @@
3234
*
3335
* @author Moritz Halbritter
3436
*/
35-
class ApplicationInfoPropertySource extends MapPropertySource {
37+
class ApplicationInfoPropertySource extends MapPropertySource implements OriginLookup<String> {
3638

3739
static final String NAME = "applicationInfo";
3840

@@ -44,6 +46,16 @@ class ApplicationInfoPropertySource extends MapPropertySource {
4446
super(NAME, getProperties(applicationVersion));
4547
}
4648

49+
@Override
50+
public Origin getOrigin(String key) {
51+
return null;
52+
}
53+
54+
@Override
55+
public boolean isImmutable() {
56+
return true;
57+
}
58+
4759
private static Map<String, Object> getProperties(String applicationVersion) {
4860
Map<String, Object> result = new HashMap<>();
4961
if (StringUtils.hasText(applicationVersion)) {

0 commit comments

Comments
 (0)