Skip to content

Commit 3187b53

Browse files
wu-shengclaude
andcommitted
Fix review comments from copilot
- Add equals/hashCode to ThreadPolicy, replace toString() comparison in shared scheduler mismatch detection with proper equals(). - Duplicate queue name check was already fixed in previous commit. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 92f8b05 commit 3187b53

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

oap-server/server-library/library-batch-queue/src/main/java/org/apache/skywalking/oap/server/library/batchqueue/BatchQueueManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ static ScheduledExecutorService getOrCreateSharedScheduler(final String name,
8080
final ThreadPolicy threads) {
8181
SHARED_SCHEDULER_POLICIES.compute(name, (k, existing) -> {
8282
if (existing != null) {
83-
if (!existing.toString().equals(threads.toString())) {
83+
if (!existing.equals(threads)) {
8484
log.warn("Shared scheduler [{}]: ThreadPolicy mismatch. "
8585
+ "Existing={}, requested={}. Using existing.",
8686
name, existing, threads);

oap-server/server-library/library-batch-queue/src/main/java/org/apache/skywalking/oap/server/library/batchqueue/ThreadPolicy.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,29 @@ public int resolve() {
9494
return Math.max(1, base + (int) Math.round(cpuMultiplier * Runtime.getRuntime().availableProcessors()));
9595
}
9696

97+
@Override
98+
public boolean equals(final Object o) {
99+
if (this == o) {
100+
return true;
101+
}
102+
if (o == null || getClass() != o.getClass()) {
103+
return false;
104+
}
105+
final ThreadPolicy that = (ThreadPolicy) o;
106+
return fixedCount == that.fixedCount
107+
&& base == that.base
108+
&& Double.compare(that.cpuMultiplier, cpuMultiplier) == 0;
109+
}
110+
111+
@Override
112+
public int hashCode() {
113+
int result = fixedCount;
114+
result = 31 * result + base;
115+
final long temp = Double.doubleToLongBits(cpuMultiplier);
116+
result = 31 * result + (int) (temp ^ (temp >>> 32));
117+
return result;
118+
}
119+
97120
@Override
98121
public String toString() {
99122
if (fixedCount > 0) {

0 commit comments

Comments
 (0)