Skip to content

Commit

Permalink
Explicit specification of content types in config replaces defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
bradAtTraceable committed Aug 16, 2022
1 parent 1ce75c6 commit c2a67eb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ private static String convertYamlToJson(InputStream yaml) throws IOException {

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

if (originalList != null) {
if (originalList != null && originalList.size() > 0) {
returnSet.addAll(originalList);
} else {
returnSet.addAll(defaultSupplier.get());
}

returnSet.addAll(defaultSupplier.get());

return returnSet;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ public class HypertraceConfigTest {
private static final String[] EXPECTED_CONTENT_TYPES =
new String[] {"json", "graphql", "xml", "x-www-form-urlencoded"};

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

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

testAllowedContentTypes(agentConfig, EXPECTED_CONTENT_TYPES_WITH_ADDITIONS);
testAllowedContentTypes(agentConfig, EXPECTED_CONTENT_TYPES_WITH_OVERRIDES);
}
}

0 comments on commit c2a67eb

Please sign in to comment.