Skip to content

Commit 957d9c9

Browse files
committed
refactor exception catching in StableConfigSource
1 parent 0baccfd commit 957d9c9

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

internal-api/src/main/java/datadog/trace/bootstrap/config/provider/StableConfigSource.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,21 +38,24 @@ public final class StableConfigSource extends ConfigProvider.Source {
3838
try {
3939
log.debug("Stable configuration file found at path: {}", file);
4040
cfg = StableConfigParser.parse(filePath);
41-
} catch (StableConfigMappingException
42-
| IllegalArgumentException
43-
| ClassCastException
44-
| NullPointerException e) {
45-
log.warn("YAML mapping error in stable configuration file {}: {}", filePath, e.getMessage());
46-
cfg = StableConfig.EMPTY;
47-
} catch (Exception e) {
48-
if (log.isDebugEnabled()) {
41+
} catch (Throwable e) {
42+
if (e instanceof StableConfigMappingException
43+
|| e instanceof IllegalArgumentException
44+
|| e instanceof ClassCastException
45+
|| e instanceof NullPointerException) {
46+
log.warn(
47+
"YAML mapping error in stable configuration file {}: {}", filePath, e.getMessage());
48+
cfg = StableConfig.EMPTY;
49+
} else if (log.isDebugEnabled()) {
4950
log.error("Unexpected error while reading stable configuration file {}: {}", filePath, e);
51+
cfg = StableConfig.EMPTY;
5052
} else {
5153
log.error(
5254
"Unexpected error while reading stable configuration file {}: {}",
5355
filePath,
5456
e.getMessage());
5557
}
58+
5659
cfg = StableConfig.EMPTY;
5760
}
5861
this.config = cfg;

0 commit comments

Comments
 (0)