Skip to content

Commit 4b770a0

Browse files
committed
fix
1 parent 08a16d6 commit 4b770a0

File tree

1 file changed

+15
-9
lines changed
  • instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/internal

1 file changed

+15
-9
lines changed

instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/internal/DeprecatedConfigProperties.java

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import static java.util.logging.Level.WARNING;
99

1010
import java.util.logging.Logger;
11+
import org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent;
1112

1213
/**
1314
* This class is internal and is hence not for public use. Its APIs are unstable and can change at
@@ -18,19 +19,24 @@ public final class DeprecatedConfigProperties {
1819

1920
private static final Logger logger = Logger.getLogger(DeprecatedConfigProperties.class.getName());
2021

21-
public static boolean getBoolean(
22-
InstrumentationConfig config,
22+
public static Boolean getBoolean(
23+
ApplicationEnvironmentPreparedEvent event,
2324
String deprecatedPropertyName,
24-
String newPropertyName,
25-
boolean defaultValue) {
26-
warnIfUsed(config, deprecatedPropertyName, newPropertyName);
27-
boolean value = config.getBoolean(deprecatedPropertyName, defaultValue);
28-
return config.getBoolean(newPropertyName, value);
25+
String newPropertyName) {
26+
warnIfUsed(event, deprecatedPropertyName, newPropertyName);
27+
Boolean value = event.getEnvironment().getProperty(deprecatedPropertyName, Boolean.class);
28+
if (value != null) {
29+
return value;
30+
}
31+
return event.getEnvironment().getProperty(newPropertyName, Boolean.class);
2932
}
3033

3134
private static void warnIfUsed(
32-
InstrumentationConfig config, String deprecatedPropertyName, String newPropertyName) {
33-
if (config.getString(deprecatedPropertyName) != null) {
35+
ApplicationEnvironmentPreparedEvent event,
36+
String deprecatedPropertyName,
37+
String newPropertyName) {
38+
String value = event.getEnvironment().getProperty(deprecatedPropertyName, String.class);
39+
if (value != null) {
3440
logger.log(
3541
WARNING,
3642
"Deprecated property \"{0}\" was used; use the \"{1}\" property instead",

0 commit comments

Comments
 (0)