Skip to content

[refactor] Use Collections.emptyList() instead of new ArrayList<> for better code quality#39

Open
Senrian wants to merge 655 commits intodevelopfrom
refactor/collections-emptylist-v1
Open

[refactor] Use Collections.emptyList() instead of new ArrayList<> for better code quality#39
Senrian wants to merge 655 commits intodevelopfrom
refactor/collections-emptylist-v1

Conversation

@Senrian
Copy link
Copy Markdown
Owner

@Senrian Senrian commented Mar 3, 2026

Description

Replace return new ArrayList<>() with Collections.emptyList() for better code quality and performance.

Collections.emptyList() returns a singleton immutable empty list, avoiding unnecessary object allocation.

Changes

  • proxy/src/main/java/org/apache/rocketmq/proxy/service/route/MessageQueueSelector.java - 2 changes
  • store/src/main/java/org/apache/rocketmq/store/MappedFileQueue.java - 1 change
  • test/src/main/java/org/apache/rocketmq/test/util/StatUtil.java - 1 change
  • tieredstore/src/main/java/org/apache/rocketmq/tieredstore/util/MessageFormatUtil.java - 1 change

Total: 4 files, 5 changes

Testing

Existing unit tests should cover these changes.

Signed-off-by: Senrian senri.an@outlook.com

lollipopjin and others added 30 commits April 16, 2025 15:30
* [#ISSUE 9333] Use fastjson2 in broker module

* Update

* Fix the serialization failure caused by improper get/set naming
* add scheduled clean task.

* make code compatible to lmq.

* make code compatible to lmq.

* make code compatible to lmq.

* make code compatible to lmq.
…pache#9384)

* [ISSUE apache#9379] Fix timeStoreTable delete logic in IndexService

* [ISSUE apache#9379] Fix delete logic from TimeStoreTable in IndexService
Add RocketmqTraffic appender to rmq.proxy.logback.xml (apache#8630)
…al file (apache#9413)

* flush bak file before delete original file.

* timer metrics.

* english comment.
… between master and slave when the topic has attributes (apache#9404)
Kris20030907 and others added 30 commits January 30, 2026 10:04
… shutdown (apache#10060)

* fix(store): close all consume queue file handles on ConsumeQueueStore shutdown

* remove implementation

---------

Co-authored-by: RongtongJin <user@example.com>
Problem: The cleanUnusedResource method was cleaning up client long polling requests without returning results to clients, causing client errors.

Solution:
1. Simplified the cleanUnusedResource method to only remove entries with empty request queues
2. Changed cleanup interval from 5 minutes to 3 minutes

Change-Id: If7052ba0d088e68cf654e6b7efafe09f5fa877be
…t flushed consume queue storetime (apache#10074)

* Fix StoreCheckpoint: set logicsMsgTimestamp only after CQ flush, use logicsMsgTempTimestamp for in-memory storetime

Change-Id: I6085bf6efaef84168ece31d080481717465f2b13

* rename to tmpLogicsMsgTimestamp

Change-Id: Ia65ca06751f765bdc2bf053c58e08789f4b2fb22

---------

Co-authored-by: guyinyou <guyinyou.gyy@alibaba-inc.com>
…ckpoint after CQ flush (apache#10080)

Change-Id: I57c0922bb81c2d43359867e82a92fdf2deab7ad7

Co-authored-by: guyinyou <guyinyou.gyy@alibaba-inc.com>
…#10096)

Signed-off-by: Shubham Kalloli <shubham.kalloli@est.tech>
Signed-off-by: Shubham Kalloli <shubham.kalloli@est.tech>
Signed-off-by: Shubham Kalloli <shubham.kalloli@est.tech>
Signed-off-by: Shubham Kalloli <shubham.kalloli@est.tech>
…or code (apache#10012)

* When IndexRocksDBEnable or TransRocksDBEnable are enabled, we need to take these two offsets into account to accelerate recovery.

* Add UTs

* Refactor the code based on the review comments

* Revert "[ISSUE apache#8127]Optimize the metric calculation logic of the time wheel"

* Remove useless import

* Refactor Code

* Refactor Code

* Refactor Code

* Refactor Code

* Refactor Code

* Implement accelerated recovery for the file-based ConsumeQueue.

* Implement accelerated recovery for the file-based ConsumeQueue.

Change-Id: Ieac45d0582f2f83d977aeb8e6f5084268b7f8752

* Implement accelerated recovery for the file-based ConsumeQueue.

* Ignore testTruncateCQ UT

---------

Co-authored-by: RongtongJin <user@example.com>
Replace return new ArrayList<>() with Collections.emptyList() for better
code quality and performance. Collections.emptyList() returns a singleton
immutable empty list, avoiding unnecessary object allocation.

Signed-off-by: Senrian <senri.an@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.