diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/ElasticApmTracer.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/ElasticApmTracer.java index 3f9a09a6076..8273b1f8d1e 100644 --- a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/ElasticApmTracer.java +++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/ElasticApmTracer.java @@ -378,11 +378,14 @@ public ConfigurationRegistry getConfigurationRegistry() { @Override @SuppressWarnings({"unchecked", "rawtypes"}) public T getConfig(Class 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) { diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/NoopTracer.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/NoopTracer.java index 76dc5f7db76..aff87d21c47 100644 --- a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/NoopTracer.java +++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/NoopTracer.java @@ -169,7 +169,7 @@ public T require(Class type) { @Override public T getConfig(Class configuration) { - return null; + throw new IllegalStateException(); } @Override