From 6c2ae77240dd21e966cd26212018385a068561e8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Vonheiden?= <bjoern.vonheiden@hotmail.de>
Date: Mon, 27 Jul 2020 11:25:13 +0200
Subject: [PATCH] Fix check for correct configuration valuen in
 WorkloadGeneratorBuilder

As ints will not be null on a null check, better check for the values
of an int.
---
 .../generators/KafkaWorkloadGeneratorBuilder.java        | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/workload-generator-commons/src/main/java/theodolite/commons/workloadgeneration/generators/KafkaWorkloadGeneratorBuilder.java b/workload-generator-commons/src/main/java/theodolite/commons/workloadgeneration/generators/KafkaWorkloadGeneratorBuilder.java
index ec4504b01..785087c13 100644
--- a/workload-generator-commons/src/main/java/theodolite/commons/workloadgeneration/generators/KafkaWorkloadGeneratorBuilder.java
+++ b/workload-generator-commons/src/main/java/theodolite/commons/workloadgeneration/generators/KafkaWorkloadGeneratorBuilder.java
@@ -155,9 +155,14 @@ public final class KafkaWorkloadGeneratorBuilder<T extends SpecificRecord> { //
    * @return the built instance of the {@link KafkaWorkloadGenerator}.
    */
   public KafkaWorkloadGenerator<T> build() {
-    Objects.requireNonNull(this.instances, "Please specify the number of instances.");
+    if (this.instances < 1) { // NOPMD
+      throw new IllegalArgumentException(
+          "Please specify a valid number of instances. Currently: " + this.instances);
+    }
     Objects.requireNonNull(this.zooKeeper, "Please specify the ZooKeeper instance.");
-    this.threads = Objects.requireNonNullElse(this.threads, 1);
+    if (this.threads < 1) { // NOPMD
+      this.threads = 1;
+    }
     Objects.requireNonNull(this.keySpace, "Please specify the key space.");
     Objects.requireNonNull(this.period, "Please specify the period.");
     Objects.requireNonNull(this.duration, "Please specify the duration.");
-- 
GitLab