-
Notifications
You must be signed in to change notification settings - Fork 562
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
9854: Allow relaxed instantiation of exporter configuration r=npepinpe a=npepinpe ## Description This PR fixes a bug where deserialization of exporter configuration was case sensitive, such that a property `NUMBEROFSHARDS` would not map to an instance field `numberOfShards`. This isn't perfect, as now if we have two fields with the same name but different cases, only one of them will be set, using the latest value in the map (where the order is undefined). It should solve the most common cases however. ## Related issues closes #7628 Co-authored-by: Nicolas Pepin-Perreault <nicolas.pepin-perreault@camunda.com>
- Loading branch information
Showing
8 changed files
with
83 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
broker/src/test/java/io/camunda/zeebe/broker/exporter/context/ExporterConfigurationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH under | ||
* one or more contributor license agreements. See the NOTICE file distributed | ||
* with this work for additional information regarding copyright ownership. | ||
* Licensed under the Zeebe Community License 1.1. You may not use this file | ||
* except in compliance with the Zeebe Community License 1.1. | ||
*/ | ||
package io.camunda.zeebe.broker.exporter.context; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.util.Map; | ||
import org.junit.jupiter.api.parallel.Execution; | ||
import org.junit.jupiter.api.parallel.ExecutionMode; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.ValueSource; | ||
|
||
@Execution(ExecutionMode.CONCURRENT) | ||
final class ExporterConfigurationTest { | ||
@ParameterizedTest | ||
@ValueSource(strings = {"numberofshards", "numberOfShards", "NUMBEROFSHARDS"}) | ||
void shouldInstantiateConfigWithCaseInsensitiveProperties(final String property) { | ||
// given | ||
final var args = Map.<String, Object>of(property, 1); | ||
final var expected = new Config(1); | ||
final var config = new ExporterConfiguration("id", args); | ||
|
||
// when | ||
final var instance = config.instantiate(Config.class); | ||
|
||
// then | ||
assertThat(instance).isEqualTo(expected); | ||
} | ||
|
||
@ParameterizedTest | ||
@ValueSource(strings = {"numberofshards", "numberOfShards", "NUMBEROFSHARDS"}) | ||
void shouldInstantiateNestedConfigWithCaseInsensitiveProperties(final String property) { | ||
// given | ||
final var args = Map.<String, Object>of("nested", Map.of(property, 1)); | ||
final var expected = new ContainerConfig(new Config(1)); | ||
final var config = new ExporterConfiguration("id", args); | ||
|
||
// when | ||
final var instance = config.instantiate(ContainerConfig.class); | ||
|
||
// then | ||
assertThat(instance).isEqualTo(expected); | ||
} | ||
|
||
private record Config(int numberOfShards) {} | ||
|
||
private record ContainerConfig(Config nested) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters