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

[ROCKETMQ-111] fix possible MQClientException when query message before today #69

Closed
wants to merge 4 commits into from

Conversation

scaat
Copy link

@scaat scaat commented Feb 24, 2017

JIRA:https://issues.apache.org/jira/browse/ROCKETMQ-111
Using "cal.set(Calendar.HOUR,0);" when query message before today which may result in :
"org.apache.rocketmq.client.exception.MQClientException: CODE: 208 DESC: query message by key finished, but no message. "
"HOUR" is used for the 12-hour clock.This will cause the start time of the query message to be greater than the creation time of the message.
Implemenations:
Using "HOUR_OF_DAY" instead of "HOUR"."HOUR_OF_DAY" is used for the 24-hour clock.
Is that so?@Jaskey @zhouxinyu

@Jaskey
Copy link
Contributor

Jaskey commented Feb 24, 2017

Hi @yilingfeng , please modify your PR subject and mention your jira address in the description, you can follow this PR. #5

Copy link
Member

@zhouxinyu zhouxinyu left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @yilingfeng , and please relate the JIRA issue.

Please @vongosling @lizhanhui help review.

@scaat scaat changed the title fix possible MQClientException when query message before today [ROCKETMQ-111] fix possible MQClientException when query message before today Feb 25, 2017
@coveralls
Copy link

coveralls commented Feb 25, 2017

Coverage Status

Coverage increased (+0.06%) to 31.58% when pulling 45647c0 on yilingfeng:master into 573b22c on apache:master.

@lizhanhui
Copy link
Contributor

Good catch.
Looks good to me.

@vongosling
Copy link
Member

+1

@Jaskey
Copy link
Contributor

Jaskey commented Feb 28, 2017

From java doc, 0 of HOUR is representing noon or midnight.

So this problem exists if we call the methods after 12:Am, the actualy hour will becomes 12 rather than 0, which may result in problems.

Good catch and nice job.

FYI:

you could try with different system clock, which will give you a different result.

    Calendar cal = Calendar.getInstance();
    cal.set(Calendar.DAY_OF_MONTH, 1);
    cal.set(Calendar.HOUR, 0);
    cal.set(Calendar.MINUTE, 0);
    cal.set(Calendar.SECOND, 0);
    cal.set(Calendar.MILLISECOND, 0);

    System.out.println(new Date(cal.getTimeInMillis()));
    System.out.println(cal.get(Calendar.AM_PM));

@shroman
Copy link
Contributor

shroman commented Feb 28, 2017

Good catch. I would add unit tests though ;)

@scaat
Copy link
Author

scaat commented Feb 28, 2017

Thank you for your detailed and clear explanation. It was very helpful and understandable. @Jaskey

@zhouxinyu
Copy link
Member

@shroman , this PR will be merged soon, looking forward to your unit tests..😀😀😀😀

asfgit pushed a commit that referenced this pull request Feb 28, 2017
@shroman
Copy link
Contributor

shroman commented Mar 8, 2017

@zhouxinyu Probably you misunderstood what I meant :) -- this PR needs unit tests. I think it's the responsibility of the person who submitted PR to create them, whenever possible, since it reflects his/her intentions.
@yilingfeng Can you please add unit tests?

@scaat
Copy link
Author

scaat commented Mar 8, 2017

Ok,I've added a unit test. @lizhanhui @shroman

@vongosling
Copy link
Member

thanks @yilingfeng . Consider this PR has been merged, we will commit your unit-test in another commit. @shroman I have a same understand as @zhouxinyu about your unit-test said :-)

@shroman
Copy link
Contributor

shroman commented Mar 8, 2017

@vongosling I meant "If I were you, I would ..." :) Anyway, I don't see why this pr can be merged without a unit test that can be easily written. I think we have to accept PRs with tests, except for the cases when they cannot be implemented.
Ok, then let's close this pr? and tests can be submitted in another one.

@yilingfeng I had a quick look, and here is what I think.
Better name the file MessageClientIDSetterTest.java and have tests for getNearlyTimeFromID() etc. instead of implementing another method and testing it in your unit test class.

@scaat
Copy link
Author

scaat commented Mar 8, 2017

Sorry, I’ve modified the unit tests. @shroman

@shroman
Copy link
Contributor

shroman commented Mar 8, 2017

@yilingfeng Great 👍 But let's have a new PR for that, as @vongosling commented above (if I understood it correctly)?

@scaat
Copy link
Author

scaat commented Mar 9, 2017

What does it mean? @vongosling @shroman

@zhouxinyu
Copy link
Member

Hi @yilingfeng @shroman , there is no need to open a new PR, the new commit will be merged to develop branch directly.

@shroman
Copy link
Contributor

shroman commented Mar 9, 2017

@zhouxinyu Thanks for clarifying it! ;)
If we don't want to test the private method too, I am ok with the tests now to be merged.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling e91b850 on yilingfeng:master into ** on apache:master**.

2 similar comments
@coveralls
Copy link

Coverage Status

Changes Unknown when pulling e91b850 on yilingfeng:master into ** on apache:master**.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling e91b850 on yilingfeng:master into ** on apache:master**.

@vongosling
Copy link
Member

@yilingfeng Could you close this PR. We have merged this pull request 29 days ago.

@scaat scaat closed this Mar 29, 2017
asfgit pushed a commit that referenced this pull request Jun 6, 2017
JiaMingLiu93 pushed a commit to JiaMingLiu93/rocketmq that referenced this pull request May 28, 2020
JiaMingLiu93 pushed a commit to JiaMingLiu93/rocketmq that referenced this pull request May 28, 2020
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.

None yet

7 participants