Skip to content

Commit 6af1d6b

Browse files
committed
copilot feedback
1 parent 711c13f commit 6af1d6b

2 files changed

Lines changed: 7 additions & 8 deletions

File tree

dynamic-control/src/main/java/io/opentelemetry/contrib/dynamic/policy/registry/PolicyInitConfig.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -255,17 +255,15 @@ private static DeclarativeConfigProperties getGeneralDeclarativeConfig(
255255
ConfigProvider configProvider) {
256256
// Prefer the general config accessor when available in the API/runtime.
257257
try {
258-
Method method = configProvider.getClass().getDeclaredMethod("getGeneralConfig");
259-
if (!method.isAccessible()) {
260-
method.setAccessible(true);
261-
}
258+
Method method = configProvider.getClass().getMethod("getGeneralConfig");
262259
Object maybeConfig = method.invoke(configProvider);
263260
if (maybeConfig instanceof DeclarativeConfigProperties) {
264261
return (DeclarativeConfigProperties) maybeConfig;
265262
}
266-
} catch (NoSuchMethodException ignored) {
267-
// Fall through to backwards-compatible accessor below.
268-
} catch (IllegalAccessException | InvocationTargetException ignored) {
263+
} catch (NoSuchMethodException
264+
| IllegalAccessException
265+
| InvocationTargetException
266+
| RuntimeException ignored) {
269267
// Fall through to backwards-compatible accessor below.
270268
}
271269
return configProvider.getGeneralInstrumentationConfig();

dynamic-control/src/test/java/io/opentelemetry/contrib/dynamic/policy/registry/PolicyInitConfigTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ private static DeclarativeConfigProperties mappingConfig() {
336336
return mapping;
337337
}
338338

339+
@SuppressWarnings("EffectivelyPrivate")
339340
private static final class ConfigProviderWithGeneralConfig implements ConfigProvider {
340341
private final DeclarativeConfigProperties generalConfig;
341342

@@ -349,7 +350,7 @@ public DeclarativeConfigProperties getInstrumentationConfig() {
349350
}
350351

351352
@SuppressWarnings("unused")
352-
DeclarativeConfigProperties getGeneralConfig() {
353+
public DeclarativeConfigProperties getGeneralConfig() {
353354
return generalConfig;
354355
}
355356
}

0 commit comments

Comments
 (0)