Removing deprecated DMAAP library
[policy/drools-pdp.git] / feature-pooling-messages / src / main / java / org / onap / policy / drools / pooling / state / ProcessingState.java
@@ -3,6 +3,7 @@
  * ONAP
  * ================================================================================
  * Copyright (C) 2018, 2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -41,6 +42,7 @@ import org.slf4j.LoggerFactory;
 /**
  * Any state in which events are being processed locally and forwarded, as appropriate.
  */
+@Setter
 @Getter
 public class ProcessingState extends State {
 
@@ -50,7 +52,6 @@ public class ProcessingState extends State {
      * Current known leader, never {@code null}.
      */
     @NonNull
-    @Setter
     private String leader;
 
     /**
@@ -61,13 +62,9 @@ public class ProcessingState extends State {
      *        leader. Never {@code null}
      * @throws IllegalArgumentException if an argument is invalid
      */
-    public ProcessingState(PoolingManager mgr, String leader) {
+    public ProcessingState(PoolingManager mgr, @NonNull String leader) {
         super(mgr);
 
-        if (leader == null) {
-            throw new IllegalArgumentException("null leader");
-        }
-
         BucketAssignments assignments = mgr.getAssignments();
 
         if (assignments != null) {
@@ -264,6 +261,7 @@ public class ProcessingState extends State {
         for (Integer index : buckets) {
             // add it to the host with the shortest bucket list
             HostBucket newhb = assignments.pollFirst();
+            assert newhb != null;
             newhb.add(index);
 
             // put the item back into the queue, with its new count
@@ -291,6 +289,7 @@ public class ProcessingState extends State {
             HostBucket smaller = assignments.pollFirst();
             HostBucket larger = assignments.pollLast();
 
+            assert larger != null && smaller != null;
             if (larger.size() - smaller.size() <= 1) {
                 // it's as balanced as it will get
                 break;