You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by dw...@apache.org on 2021/12/17 15:18:38 UTC
[flink] 02/03: [hotfix] Make PseudoRandomValueSelector return the selected value
This is an automated email from the ASF dual-hosted git repository.
dwysakowicz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git
commit 591f3157fead32e06565cd9f4774bb7e48695fab
Author: Dawid Wysakowicz <dw...@apache.org>
AuthorDate: Fri Dec 10 09:36:07 2021 +0100
[hotfix] Make PseudoRandomValueSelector return the selected value
---
.../flink/runtime/testutils/PseudoRandomValueSelector.java | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/testutils/PseudoRandomValueSelector.java b/flink-runtime/src/test/java/org/apache/flink/runtime/testutils/PseudoRandomValueSelector.java
index 6944de7..7b545ad 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/testutils/PseudoRandomValueSelector.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/testutils/PseudoRandomValueSelector.java
@@ -66,14 +66,15 @@ public class PseudoRandomValueSelector {
this.randomValueSupplier = randomValueSupplier;
}
- public <T> void select(Configuration configuration, ConfigOption<T> option, T... alternatives) {
+ public <T> T select(Configuration configuration, ConfigOption<T> option, T... alternatives) {
if (configuration.contains(option)) {
- return;
+ return configuration.get(option);
}
final int choice = randomValueSupplier.apply(alternatives.length);
T value = alternatives[choice];
LOG.info("Randomly selected {} for {}", value, option.key());
configuration.set(option, value);
+ return value;
}
public static PseudoRandomValueSelector create(Object entryPointSeed) {
@@ -124,10 +125,10 @@ public class PseudoRandomValueSelector {
return Optional.empty();
}
- public static <T> void randomize(Configuration conf, ConfigOption<T> option, T... t1) {
+ public static <T> T randomize(Configuration conf, ConfigOption<T> option, T... t1) {
final String testName = TestNameProvider.getCurrentTestName();
final PseudoRandomValueSelector valueSelector =
PseudoRandomValueSelector.create(testName != null ? testName : "unknown");
- valueSelector.select(conf, option, t1);
+ return valueSelector.select(conf, option, t1);
}
}