Skip to content

[ROCKETMQ-6] Use logger for exceptions instead of e.printStackTrace().#3

Closed
shroman wants to merge 8 commits into
apache:developfrom
shroman:ROCKETMQ-6
Closed

[ROCKETMQ-6] Use logger for exceptions instead of e.printStackTrace().#3
shroman wants to merge 8 commits into
apache:developfrom
shroman:ROCKETMQ-6

Conversation

@shroman

@shroman shroman commented Dec 22, 2016

Copy link
Copy Markdown
Contributor

@vongosling

Copy link
Copy Markdown
Member

@shroman Thanks your PR

Could you abide our PR process(modify your PR subject and mention your jira address in the description), please follow this PR. #5

@shroman

shroman commented Dec 23, 2016

Copy link
Copy Markdown
Contributor Author

@vongosling sure, but where can I find the description of the process?

Btw, modifying the subject, etc. can be done when you merge.

@shroman shroman changed the title Logging instead of printStack(). Fix for ROCKETMQ-6. [ROCKETMQ-6] Use logger for exceptions instead of e.printStackTrace(). Dec 23, 2016
@shroman

shroman commented Dec 23, 2016

Copy link
Copy Markdown
Contributor Author

@vongosling I modified as you requested ;) Please have a look.

@shroman shroman force-pushed the ROCKETMQ-6 branch 2 times, most recently from 4114084 to 297d903 Compare December 28, 2016 10:53
@lollipopjin

Copy link
Copy Markdown
Contributor

@shroman Could you please squash your commits and fix conflicts.

@shroman

shroman commented Dec 29, 2016

Copy link
Copy Markdown
Contributor Author

@lollipopjin I resolved the conflicts, now you can review.
How about squashing all commits when you merge after reviewing this issue? My concern is -- I merged this to the master, so if I squash, it will be very hard for you to review.

@zhouxinyu

Copy link
Copy Markdown
Member

Hi, @shroman

About e.printStackTrace(), the error message should log to file surely, but can we keep the e.printStackTrace() if the call stack is in broker start process. IMO, print the error message to stderr will be more visualized, the developers can quick locate the reason why broker start failed.

And I have another question, why this PR prefer to use + to concat string instead of using format string?

@shroman

shroman commented Jan 10, 2017

Copy link
Copy Markdown
Contributor Author

Hi @zhouxinyu

I am not sure if I understand your 1st point though, but if you are saying about printing to stdout or stderr so that users can find problems with brokers from the command line, for instance, quickly,
I think this can be configured via logger xml configuration, right?

As for the 2nd point, I used + just because I am not sure what is the preferred way for the project -- both + and {} through the project. Shall we make a rule for this in http://rocketmq.apache.org/docs/code-guidelines/?

@lizhanhui

Copy link
Copy Markdown
Contributor

@shroman Please use parameterized template formatting way. See http://slf4j.org/faq.html section "What is the fastest way of (not) logging?"

@shroman

shroman commented Jan 10, 2017

Copy link
Copy Markdown
Contributor Author

@lizhanhui Ok. I changed my modifications to parameterized template formatting.

@zhouxinyu If you feel this issue needs more careful logging consideration, I don't mind if you assign this JIRA issue to yourself ;) You are working with the project on the daily basis and can tune it better.
Anyway, I think it's better to move stdout logging to slf4j etc. as much as possible.

@vongosling

Copy link
Copy Markdown
Member

IMO, we should prefer slf4j or String.format effective format way to log in 4.x :-)

@shroman

shroman commented Jan 11, 2017

Copy link
Copy Markdown
Contributor Author

@vongosling I completely agree with you

@wu-sheng wu-sheng left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Only one suggestion.


if (LOG.isDebugEnabled()) {
LOG.debug("receive PullMessage request command, {}", request);
if (log.isDebugEnabled()) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

log.isDebugEnabled() is not necessary, and do not consistent with other codes log-style.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

How is it related to this PR? Please see the title.
That is from the original code, probably you can find ten more small improvements in files I edited but lines I haven't even touched ;)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

No related, just think you can change

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

For this particular place, this can be removed, I agree. But it is good to concenrate the attention on what PR is about.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Agree. Next time, I can bring a new pull request after yours merged.

@wu-sheng wu-sheng left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

👏🏻👏🏻💪

@dongeforever

Copy link
Copy Markdown
Member

@shroman please resolve the conflicts and merge this PR

if (log != null) {
log.info(name + "=" + value);
if (logger != null) {
logger.info(name + "=" + value);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

please replace {} with + :-)

this.thread.join(this.getJointime());
long eclipseTime = System.currentTimeMillis() - beginTime;
STLOG.info("join thread " + this.getServiceName() + " eclipse time(ms) " + eclipseTime + " "
log.info("join thread " + this.getServiceName() + " eclipse time(ms) " + eclipseTime + " "

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

the same question :-)

public void stop(final boolean interrupt) {
this.stopped = true;
STLOG.info("stop thread " + this.getServiceName() + " interrupt " + interrupt);
log.info("stop thread " + this.getServiceName() + " interrupt " + interrupt);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

the same

public void makeStop() {
this.stopped = true;
STLOG.info("makestop thread " + this.getServiceName());
log.info("makestop thread " + this.getServiceName());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

the same

@vongosling

Copy link
Copy Markdown
Member

any update? or close it :-)

@shroman

shroman commented Jul 4, 2017

Copy link
Copy Markdown
Contributor Author

Ok, if it's good to merge, I will resolve the conflicts and merge.

@shroman shroman changed the base branch from master to develop July 5, 2017 10:56
@shroman shroman closed this Jul 5, 2017
@shroman

shroman commented Jul 5, 2017

Copy link
Copy Markdown
Contributor Author

Merged to develop branch.

@coveralls

coveralls commented Jul 5, 2017

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-12.4%) to 26.315% when pulling 0baccb7 on shroman:ROCKETMQ-6 into 9ad9ad0 on apache:develop.

1 similar comment
@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-12.4%) to 26.315% when pulling 0baccb7 on shroman:ROCKETMQ-6 into 9ad9ad0 on apache:develop.

wlliqipeng pushed a commit that referenced this pull request Mar 11, 2019
JiaMingLiu93 pushed a commit to JiaMingLiu93/rocketmq that referenced this pull request May 28, 2020
duhenglucky pushed a commit that referenced this pull request Jul 11, 2022
johnluoyx added a commit to johnluoyx/rocketmq that referenced this pull request Jun 30, 2023
# This is the 1st commit message:

add acl event

Signed-off-by: lyx <1419360299@qq.com>

# This is the commit message apache#2:

add update acl config event

Signed-off-by: lyx <1419360299@qq.com>

# This is the commit message apache#3:

refactor(event): fix rename

Signed-off-by: lyx <1419360299@qq.com>

# This is the commit message apache#4:

refactor(acl): track acl update event

Signed-off-by: lyx <1419360299@qq.com>

# Conflicts:
#	acl/src/main/java/org/apache/rocketmq/acl/plain/PlainPermissionManager.java
pulllock pushed a commit to pulllock/rocketmq that referenced this pull request Oct 19, 2023
Aias00 added a commit to Aias00/rocketmq that referenced this pull request Jul 10, 2026
… removals

Two gaps in addCompleteSubscription's quota gate (follow-up apache#3):

1. State leak on quota failure. The check ran AFTER setWildcardPatterns
   and markWildcardGroup, so a quota-exceeded throw left non-empty
   wildcardPatterns plus a wildcardGroupMap entry. reexpandWildcardPatterns
   and registerArrivingLmqForPatternClients (which key off non-empty
   patterns / the group map) then picked up the failed client and turned
   it into a deferred-effect subscription.

2. wouldAdd only counted gross additions, not crediting the lmqNames the
   same operation would remove. A net-zero replace at the quota limit
   (drop one lmq, add another) was falsely rejected.

Fix: compute lmqNameNew (expand is read-only) BEFORE any mutation,
project wouldAdd as max(0, added - removed), run checkQuotaOrThrow
first, then apply setWildcardPatterns / markWildcardGroup / add-remove.
A quota failure now leaves only the harmless empty placeholder
LiteSubscription — no patterns, no group mark, no active refs.

Tests: strengthened the pattern quota test to assert no pattern/group
state leaks; added net-zero-replace-at-quota (must pass) and a
pattern-quota-failure deferred-state test asserting later re-expand /
arriving-lmq register nothing for the rejected client.

Co-Authored-By: Claude <noreply@anthropic.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.

8 participants