From 1118550a27d24f33ec433cb8d7bdf7a77c470b6e Mon Sep 17 00:00:00 2001 From: Lari Hotari Date: Sat, 18 Jan 2025 02:25:44 +0200 Subject: [PATCH] [improve][broker] Improve Consumer.equals performance - current problem is that unefficient IP address comparison will have to be performed on every match - equals method should check if the other object is the same instance as the first step --- .../main/java/org/apache/pulsar/broker/service/Consumer.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/Consumer.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/Consumer.java index 0baba13cc0b07..b46e10a20fd34 100644 --- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/Consumer.java +++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/Consumer.java @@ -1048,6 +1048,9 @@ public CompletableFuture checkPermissionsAsync() { @Override public boolean equals(Object obj) { + if (this == obj) { + return true; + } if (obj instanceof Consumer) { Consumer other = (Consumer) obj; return consumerId == other.consumerId && Objects.equals(cnx.clientAddress(), other.cnx.clientAddress());