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

bugfix: check callback to avoid std::bad_function_call exception #456

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

zliang-min
Copy link

@zliang-min zliang-min commented Nov 22, 2024

Fixes #455

Motivation

Fixed the bug that when reading messages from a non-persistent topic with Reader, it throw std::bad_function_call exception.

Modifications

Check checkback before calling it in AckGroupingTracker.

Verifying this change

  • Make sure that the change passes the CI checks.

(Please pick either of the following options)

This change is a trivial rework / code cleanup without any test coverage.

Documentation

  • doc-required
    (Your PR needs to update docs and you will update later)

  • doc-not-needed
    (Please explain why)

A simple bug fix.

  • doc
    (Your PR contains doc changes)

  • doc-complete
    (Docs have been already added)

@shibd
Copy link
Member

shibd commented Nov 22, 2024

hi, @zliang-min Thanks for PR, can you add a unit test to cover this?

@BewareMyPower BewareMyPower added this to the 3.7.0 milestone Nov 22, 2024
@BewareMyPower BewareMyPower added the bug Something isn't working label Dec 9, 2024
Copy link
Contributor

@BewareMyPower BewareMyPower left a comment

Choose a reason for hiding this comment

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

Please fix the code style check. See https://github.com/apache/pulsar-client-cpp?tab=readme-ov-file#requirements-for-contributors for how to use clang-format 11 to format the code

int res = makePutRequest(url, "5");
LOG_INFO("res = " << res);
ASSERT_FALSE(res != 204 && res != 409);
}
}

protected:
bool isMultiTopic_ = GetParam();
std::string fullTopicName(const std::string & topicName) {
return (isNonPersistentTopic ? "non-" : "") + "persistent://public/default/" + topicName;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return (isNonPersistentTopic ? "non-" : "") + "persistent://public/default/" + topicName;
return std::string(isNonPersistentTopic ? "non-" : "") + "persistent://public/default/" + topicName;

Only std::string can be used to call operator+. Otherwise the build will fail with "Invalid operands to binary expression ('const char *' and 'const char[29]') "

int res = makePutRequest(url, "5");
LOG_INFO("res = " << res);
ASSERT_FALSE(res != 204 && res != 409);
}
}

protected:
bool isMultiTopic_ = GetParam();
std::string fullTopicName(const std::string & topicName) {
Copy link
Contributor

Choose a reason for hiding this comment

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

testPartitionIndex uses TEST but not TEST_F or TEST_P. If you're going to call this method in those tests, please change TEST to TEST_P

@BewareMyPower
Copy link
Contributor

I will start the release for 3.7.0 soon. Any chance to address the comments? If not, I can open another PR to fix it.

@BewareMyPower BewareMyPower modified the milestones: 3.7.0, 3.8.0 Dec 13, 2024
@zliang-min
Copy link
Author

I will start the release for 3.7.0 soon. Any chance to address the comments? If not, I can open another PR to fix it.

Hi @BewareMyPower sorry for the late response. I have been busy with some other work recently. You are more than welcome to open another PR for this. Or it will take a little while before I can get back to this. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] std::bad_function_call was thrown on Reader::ReadNext on a non-persistent topic
3 participants