Skip to content

Commit c2a67eb

Browse files
Explicit specification of content types in config replaces defaults
1 parent 1ce75c6 commit c2a67eb

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

otel-extensions/src/main/java/org/hypertrace/agent/otel/extensions/config/HypertraceConfig.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,8 @@ private static String convertYamlToJson(InputStream yaml) throws IOException {
222222

223223
/**
224224
* Creates a collection of objects consisting of the set of objects specified in the
225-
* configuration, plus the default set of objects.
225+
* configuration. If there are no objects in the configuration, the default set of objects is
226+
* used.
226227
*
227228
* @param originalList the set of objects specified in the configuration
228229
* @param defaultSupplier a lambda which provides the default set of objects.
@@ -234,12 +235,12 @@ private static <T> Collection<T> applyListDefaults(
234235
List<T> originalList, Supplier<List<T>> defaultSupplier) {
235236
Set<T> returnSet = new HashSet<>();
236237

237-
if (originalList != null) {
238+
if (originalList != null && originalList.size() > 0) {
238239
returnSet.addAll(originalList);
240+
} else {
241+
returnSet.addAll(defaultSupplier.get());
239242
}
240243

241-
returnSet.addAll(defaultSupplier.get());
242-
243244
return returnSet;
244245
}
245246
}

otel-extensions/src/test/java/org/hypertrace/agent/otel/extensions/config/HypertraceConfigTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ public class HypertraceConfigTest {
4040
private static final String[] EXPECTED_CONTENT_TYPES =
4141
new String[] {"json", "graphql", "xml", "x-www-form-urlencoded"};
4242

43-
private static final String[] EXPECTED_CONTENT_TYPES_WITH_ADDITIONS =
44-
new String[] {"json", "graphql", "xml", "x-www-form-urlencoded", "foo", "bar"};
43+
private static final String[] EXPECTED_CONTENT_TYPES_WITH_OVERRIDES = new String[] {"foo", "bar"};
4544

4645
@Test
4746
public void defaultValues() throws IOException {
@@ -269,6 +268,6 @@ public void nonDefaultDataCaptureConfigTest() throws IOException {
269268
URL resource = getClass().getClassLoader().getResource("nonDefaultDataCaptureConfig.yaml");
270269
AgentConfig agentConfig = HypertraceConfig.load(resource.getPath());
271270

272-
testAllowedContentTypes(agentConfig, EXPECTED_CONTENT_TYPES_WITH_ADDITIONS);
271+
testAllowedContentTypes(agentConfig, EXPECTED_CONTENT_TYPES_WITH_OVERRIDES);
273272
}
274273
}

0 commit comments

Comments
 (0)