Skip to content

Conversation

@Technoboy-
Copy link
Contributor

Motivation

Avoid call sync method in async rest API for PersistentTopicsBase#internalGetMessageById.

Documentation

  • no-need-doc

@Technoboy- Technoboy- self-assigned this Jan 21, 2022
@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Jan 21, 2022
});
}).exceptionally(ex -> {
Throwable cause = ex.getCause();
if (cause instanceof NullPointerException) {
Copy link
Member

Choose a reason for hiding this comment

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

it's weird. why we catch NPE here ?

I mean, if somewhere gets NPE, we need to check there. Shouldn't it be catching exceptions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, maybe we will fix this in another new pr. If fixed here, will be confused.

Copy link
Member

Choose a reason for hiding this comment

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

Agree with you.

Copy link
Contributor

Choose a reason for hiding this comment

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

Please drop this check.
It is the right time to get rid of this tech debt.

If someone sees the NPE we can fix it.
If we keep this now I bet no one will take care.

It is also possible that that NPE was due to some old bug

I would like to see you dropping this line

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, This is involved by 6331. Seem that we can drop this line directly.

});
}).exceptionally(ex -> {
Throwable cause = ex.getCause();
if (cause instanceof NullPointerException) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please drop this check.
It is the right time to get rid of this tech debt.

If someone sees the NPE we can fix it.
If we keep this now I bet no one will take care.

It is also possible that that NPE was due to some old bug

I would like to see you dropping this line

}
return ret.thenCompose(ignore -> {
return getTopicReferenceAsync(topicName)
.thenAccept(topic -> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to check if the topic is null?

Copy link
Contributor

Choose a reason for hiding this comment

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

we already checked that the topic is here with validateTopicOwnershipAsync
I am not sure it is needed,
in the old code we did not check for nulls

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@codelipenghui If topic does not exist, getTopicReferenceAsync will throw exception.
And I have updated the logic. Thanks for the reminder.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we already checked that the topic is here with validateTopicOwnershipAsync I am not sure it is needed, in the old code we did not check for nulls

getTopicReferenceAsync has checked and I have updated the logic here

Copy link
Contributor

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

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

+1

}
return ret.thenCompose(ignore -> {
return getTopicReferenceAsync(topicName)
.thenAccept(topic -> {
Copy link
Contributor

Choose a reason for hiding this comment

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

we already checked that the topic is here with validateTopicOwnershipAsync
I am not sure it is needed,
in the old code we did not check for nulls

@codelipenghui codelipenghui merged commit 1cb5c4b into apache:master Jan 24, 2022
@Technoboy- Technoboy- deleted the internalGetMessageById-async branch August 10, 2022 05:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc-not-needed Your PR changes do not impact docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants