Skip to content

Commit

Permalink
Throw exception on asking for configuration that is not available.
Browse files Browse the repository at this point in the history
  • Loading branch information
raphw committed Mar 8, 2023
1 parent c886ccc commit 0caaf30
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -378,11 +378,14 @@ public ConfigurationRegistry getConfigurationRegistry() {
@Override
@SuppressWarnings({"unchecked", "rawtypes"})
public <T> T getConfig(Class<T> configProvider) {
T configuration = null;
if (ConfigurationOptionProvider.class.isAssignableFrom(configProvider)) {
return (T) configurationRegistry.getConfig((Class) configProvider);
} else {
return null;
configuration = (T) configurationRegistry.getConfig((Class) configProvider);
}
if (configuration == null) {
throw new IllegalStateException("no configuration available for " + configProvider.getName());
}
return configuration;
}

public void endTransaction(Transaction transaction) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public <T extends co.elastic.apm.agent.tracer.Tracer> T require(Class<T> type) {

@Override
public <T> T getConfig(Class<T> configuration) {
return null;
throw new IllegalStateException();
}

@Override
Expand Down

0 comments on commit 0caaf30

Please sign in to comment.