Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Unused comment in Logger #869

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ruanwenjun
Copy link

No description provided.

@ruanwenjun ruanwenjun force-pushed the dev_wenjun_removeUnusedComment branch from 68f3b5d to 9015b2e Compare October 13, 2024 13:20
Comment on lines 135 to 144
}
for (final Logger child : childrenList) {
if (childName.equals(child.getName())) {
return child;
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use for-each to optimize

Copy link

@mches mches Oct 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this optimization, but I propose taking it further and ensuring that childrenList is always an instance of CopyOnWriteArrayList

    transient private List<Logger> childrenList;

↓↓↓

    transient private final List<Logger> childrenList = new CopyOnWriteArrayList<>();

or, with modifiers sorted

    private final transient List<Logger> childrenList = new CopyOnWriteArrayList<>();

Then all the null checks could be removed and there would be not even a remote possibility that childrenList's iterator could throw ConcurrentModificationException.

It may even fix some subtle visibility issues. There are some unsynchronized null checks against childrenList that may read a stale value. e.g.

    Logger createChildByLastNamePart(final String lastPart) {
        …
        if (childrenList == null) {
            ^^^^^^^^^^^^^^^^^^^^
            childrenList = new CopyOnWriteArrayList<Logger>();
        }
        …
    }

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good suggestion, I can't agree more, updated.

Comment on lines 169 to 165
for (int i = 0; i < len; i++) {
Logger child = (Logger) childrenList.get(i);
for (Logger childLogger : childrenList) {
// tell child to handle parent levelInt change
child.handleParentLevelChange(effectiveLevelInt);
childLogger.handleParentLevelChange(effectiveLevelInt);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use for-each to optimize.

Comment on lines 186 to 187
for (Logger childLogger : childrenList) {
childLogger.handleParentLevelChange(newParentLevelInt);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use for-each to optimize

Comment on lines -344 to -347
/**
* The default size of child list arrays. The JDK 1.5 default is 10. We use a
* smaller value to save a little space.
*/
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the unused comment.

Comment on lines 292 to 283
*
*
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be inclined to take out unnecessary, unrelated changes to make it easier on the maintainers

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, this is caused by my IDEA setting, now I revert this.

@ruanwenjun ruanwenjun force-pushed the dev_wenjun_removeUnusedComment branch 2 times, most recently from 4b8167c to 03cd226 Compare October 13, 2024 16:31
@ruanwenjun ruanwenjun requested a review from mches October 14, 2024 08:24
Copy link

@mches mches left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your PR title is "Remove Unused comment in LoggerContext", but the comment you removed is in Logger. In LoggerContext you removed redundant casting and type information and unused imports. These codebase modernization activities could be done en masse using tools, but don't seem to be a project priority. I'd be inclined to separate or discard inconsequential changes. In Logger you do many things other than remove a comment. I suggest focusing your PR and not neglecting the PR title and description. Maintainers appreciate an accurate title and overview.

@ruanwenjun
Copy link
Author

Your PR title is "Remove Unused comment in LoggerContext", but the comment you removed is in Logger. In LoggerContext you removed redundant casting and type information and unused imports. These codebase modernization activities could be done en masse using tools, but don't seem to be a project priority. I'd be inclined to separate or discard inconsequential changes. In Logger you do many things other than remove a comment. I suggest focusing your PR and not neglecting the PR title and description. Maintainers appreciate an accurate title and overview.

Thanks suggestions, this help me not only on this PR but in the future work. So I need to separate this PR and change the title to Remove Unused comment in Logger and focus on only remove the comment

/**
 * The default size of child list arrays. The JDK 1.5 default is 10. We use a
 * smaller value to save a little space.
 */

@mches
Copy link

mches commented Oct 15, 2024

No guarantee to get attention of maintainers, but that sounds like a focused PR to me. I encourage you to read the contribution guidelines. Wish you luck.

@ruanwenjun ruanwenjun force-pushed the dev_wenjun_removeUnusedComment branch from 03cd226 to 7419ed9 Compare October 15, 2024 13:36
@ruanwenjun ruanwenjun changed the title Remove Unused comment in LoggerContext Remove Unused comment in Logger Oct 15, 2024
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.

2 participants