Skip to content

Commit

Permalink
[fix][broker] Fix NPE after publishing a tombstone to the service uni…
Browse files Browse the repository at this point in the history
…t channel (apache#22859)

(cherry picked from commit 9326a08)
  • Loading branch information
BewareMyPower authored and heesung-sn committed Jun 26, 2024
1 parent 3dcfba1 commit 602914e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
package org.apache.pulsar.broker.loadbalance.extensions.manager;

import static com.google.common.base.Preconditions.checkArgument;
import static org.apache.pulsar.broker.loadbalance.extensions.channel.ServiceUnitState.Assigning;
import static org.apache.pulsar.broker.loadbalance.extensions.channel.ServiceUnitState.Owned;
import static org.apache.pulsar.broker.loadbalance.extensions.models.UnloadDecision.Label.Failure;
Expand Down Expand Up @@ -119,9 +120,8 @@ public void handleEvent(String serviceUnit, ServiceUnitStateData data, Throwable
}
}
case Init -> {
if (data.force()) {
complete(serviceUnit, t);
}
checkArgument(data == null, "Init state must be associated with null data");
complete(serviceUnit, t);
}
case Owned -> complete(serviceUnit, t);
default -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,7 @@ public void testSuccess() throws IllegalAccessException, ExecutionException, Int
assertEquals(inFlightUnloadRequestMap.size(), 1);

// Success with Init state.
manager.handleEvent(bundle,
new ServiceUnitStateData(ServiceUnitState.Init, null, srcBroker, false, VERSION_ID_INIT), null);
assertEquals(inFlightUnloadRequestMap.size(), 1);
manager.handleEvent(bundle,
new ServiceUnitStateData(ServiceUnitState.Init, null, srcBroker, true, VERSION_ID_INIT), null);
manager.handleEvent(bundle, null, null);
assertEquals(inFlightUnloadRequestMap.size(), 0);
future.get();
assertEquals(counter.getBreakdownCounters().get(Success).get(Admin).get(), 1);
Expand Down

0 comments on commit 602914e

Please sign in to comment.