Skip to content

Commit 6f040ae

Browse files
lhotariganesh-ctds
authored andcommitted
[fix][broker] Fix various error-prone detected errors mainly in logging and String.format parameters (apache#25059)
(cherry picked from commit 39ea19e) (cherry picked from commit 6917645)
1 parent 6b94167 commit 6f040ae

File tree

7 files changed

+12
-12
lines changed

7 files changed

+12
-12
lines changed

pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/Namespaces.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1163,7 +1163,7 @@ public void deleteSubscriptionDispatchRate(@Suspended AsyncResponse asyncRespons
11631163
internalDeleteSubscriptionDispatchRateAsync()
11641164
.thenAccept(__ -> asyncResponse.resume(Response.noContent().build()))
11651165
.exceptionally(ex -> {
1166-
log.error("Failed to delete the subscription dispatchRate for cluster on namespace {}",
1166+
log.error("[{}] Failed to delete the subscription dispatchRate for cluster on namespace {}",
11671167
clientAppId(), namespaceName, ex);
11681168
resumeAsyncResponseExceptionally(asyncResponse, ex);
11691169
return null;

pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/extensions/scheduler/SplitScheduler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public void execute() {
116116
synchronized (bundleSplitStrategy) {
117117
final Set<SplitDecision> decisions = bundleSplitStrategy.findBundlesToSplit(context, pulsar);
118118
if (debugMode) {
119-
log.info("Split Decisions:", decisions);
119+
log.info("Split Decisions: {}", decisions);
120120
}
121121
if (!decisions.isEmpty()) {
122122
// currently following the unloading timeout

pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/extensions/strategy/DefaultNamespaceBundleSplitStrategyImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ public Set<SplitDecision> findBundlesToSplit(LoadManagerContext context, PulsarS
244244
.get(conf.getMetadataStoreOperationTimeoutSeconds(), TimeUnit.SECONDS);
245245
} catch (Throwable e) {
246246
counter.update(Failure, Unknown);
247-
log.warn(String.format(CANNOT_SPLIT_BUNDLE_MSG + " Failed to get split boundaries.", bundle, e));
247+
log.warn(String.format(CANNOT_SPLIT_BUNDLE_MSG + " Failed to get split boundaries.", bundle), e);
248248
continue;
249249
}
250250
if (splitBoundary == null) {

pulsar-broker/src/main/java/org/apache/pulsar/broker/service/PulsarMetadataEventSynchronizer.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,11 +228,13 @@ private void startConsumer() {
228228
log.info("successfully created consumer {}", topicName);
229229
} else {
230230
State stateTransient = state;
231-
log.info("[{}] Closing the new consumer because the synchronizer state is {}", stateTransient);
231+
log.info("[{}] Closing the new consumer because the synchronizer state is {}", topicName,
232+
stateTransient);
232233
CompletableFuture closeConsumer = new CompletableFuture<>();
233234
closeResource(() -> consumer.closeAsync(), closeConsumer);
234235
closeConsumer.thenRun(() -> {
235-
log.info("[{}] Closed the new consumer because the synchronizer state is {}", stateTransient);
236+
log.info("[{}] Closed the new consumer because the synchronizer state is {}", topicName,
237+
stateTransient);
236238
});
237239
}
238240
}).exceptionally(ex -> {
@@ -317,7 +319,7 @@ private void closeResource(final Supplier<CompletableFuture<Void>> asyncCloseabl
317319
}
318320
// Retry.
319321
long waitTimeMs = backOff.next();
320-
log.warn("[{}] Exception: '{}' occurred while trying to close the %s. Retrying again in {} s.",
322+
log.warn("[{}] Exception: '{}' occurred while trying to close the {}. Retrying again in {} s.",
321323
topicName, ex.getMessage(), asyncCloseable.getClass().getSimpleName(), waitTimeMs / 1000.0, ex);
322324
brokerService.executor().schedule(() -> closeResource(asyncCloseable, future), waitTimeMs,
323325
TimeUnit.MILLISECONDS);

pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/GeoPersistentReplicator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ protected CompletableFuture<Void> prepareCreateProducer() {
6464
if (metadata.partitions == 0) {
6565
topicCheckFuture.complete(null);
6666
} else {
67-
String errorMsg = String.format("{} Can not create the replicator due to the partitions in the"
67+
String errorMsg = String.format("%s Can not create the replicator due to the partitions in the"
6868
+ " remote cluster is not 0, but is %s",
6969
replicatorId, metadata.partitions);
7070
log.error(errorMsg);

pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2918,13 +2918,12 @@ public CompletableFuture<? extends TopicStatsImpl> asyncGetStats(GetStatsOptions
29182918
stats.topicCreationTimeStamp = getTopicCreationTimeStamp();
29192919

29202920
stats.compaction.reset();
2921-
mxBean.flatMap(bean -> bean.getCompactionRecordForTopic(topic)).map(compactionRecord -> {
2921+
mxBean.flatMap(bean -> bean.getCompactionRecordForTopic(topic)).ifPresent(compactionRecord -> {
29222922
stats.compaction.lastCompactionRemovedEventCount = compactionRecord.getLastCompactionRemovedEventCount();
29232923
stats.compaction.lastCompactionSucceedTimestamp = compactionRecord.getLastCompactionSucceedTimestamp();
29242924
stats.compaction.lastCompactionFailedTimestamp = compactionRecord.getLastCompactionFailedTimestamp();
29252925
stats.compaction.lastCompactionDurationTimeInMills =
29262926
compactionRecord.getLastCompactionDurationTimeInMills();
2927-
return compactionRecord;
29282927
});
29292928

29302929
Map<String, CompletableFuture<SubscriptionStatsImpl>> subscriptionFutures = new HashMap<>();
@@ -2972,7 +2971,7 @@ public CompletableFuture<? extends TopicStatsImpl> asyncGetStats(GetStatsOptions
29722971
}
29732972
}
29742973
if (getStatsOptions.isGetEarliestTimeInBacklog() && stats.backlogSize != 0) {
2975-
CompletableFuture finalRes = ledger.getEarliestMessagePublishTimeInBacklog()
2974+
CompletableFuture<TopicStatsImpl> finalRes = ledger.getEarliestMessagePublishTimeInBacklog()
29762975
.thenApply((earliestTime) -> {
29772976
stats.earliestMsgPublishTimeInBacklogs = earliestTime;
29782977
return stats;

pulsar-broker/src/main/java/org/apache/pulsar/broker/stats/prometheus/NamespaceStatsAggregator.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ private static void getTopicStats(Topic topic, TopicStats stats, boolean include
326326

327327
compactorMXBean
328328
.flatMap(mxBean -> mxBean.getCompactionRecordForTopic(topic.getName()))
329-
.map(compactionRecord -> {
329+
.ifPresent(compactionRecord -> {
330330
stats.compactionRemovedEventCount = compactionRecord.getCompactionRemovedEventCount();
331331
stats.compactionSucceedCount = compactionRecord.getCompactionSucceedCount();
332332
stats.compactionFailedCount = compactionRecord.getCompactionFailedCount();
@@ -346,7 +346,6 @@ private static void getTopicStats(Topic topic, TopicStats stats, boolean include
346346
stats.compactionCompactedEntriesCount = entries;
347347
stats.compactionCompactedEntriesSize = size;
348348
}
349-
return compactionRecord;
350349
});
351350
}
352351

0 commit comments

Comments
 (0)