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

[mysql] Fix ArrayIndexOutOfBoundsException in mysql binlog read phase #911

Merged
merged 3 commits into from
Mar 7, 2022

Conversation

leonardBang
Copy link
Contributor

@leonardBang leonardBang commented Mar 4, 2022

Try to fix #460

@leonardBang leonardBang added this to the V2.2.0 milestone Mar 4, 2022
Copy link
Member

@fsk119 fsk119 left a comment

Choose a reason for hiding this comment

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

Thanks for your great work!

offset = 0;
limit = in.read(buffer, 0, buffer.length);
if (limit == -1) {
return limit;
Copy link
Member

Choose a reason for hiding this comment

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

-1 in the InputStream means EOF, which will cause the ByteArrayInputStream#fill to throw the EOF Exception. BinaryLogClient may still need to exit in its method listenForEventPackets.

I just curious in which situation we will receive -1 here? Actually the inputstream is from the Socket. I think it should never reach end ? Can we return 0 rather than -1 to represents retry here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we should return -1 here to follow the mehod java doc, reach the EOF of inpustream is expected, see more in NamedPipeSocketFactory.this.new RandomAccessFileInputStream

Copy link
Member

Choose a reason for hiding this comment

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

You are right. It should return -1 and the invoker will take over and reconnect.

Copy link
Member

@fsk119 fsk119 left a comment

Choose a reason for hiding this comment

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

LGTM

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.

[MYSQL] Caused by: java.lang.ArrayIndexOutOfBoundsException
2 participants