Skip to content

Conversation

@gortiz
Copy link
Contributor

@gortiz gortiz commented Aug 31, 2017

There is a small bug on ArrowBuf at line 750. It says:
udle.setBytes(index + offset, buf);

But it should say:
udle.setBytes(index + offset, newBuf);

There is a wraparound: You can call the method with the already sliced buffer.

@wesm
Copy link
Member

wesm commented Aug 31, 2017

This seems like a quite serious bug, perhaps this code path is never exercised? Can you add a unit test for this?

Also, would you mind opening a JIRA for the changelog and add it to the PR title? Thanks!

@gortiz gortiz changed the title [Java] Fixed a small bug on ArrowBuf.setBytes with unsliced ByteBuffers ARROW-1443: [Java] Fixed a small bug on ArrowBuf.setBytes with unsliced ByteBuffers Aug 31, 2017
@gortiz
Copy link
Contributor Author

gortiz commented Aug 31, 2017

You can bet it was a serious bug. I spent some time trying to catch it! But it was quite easy to fix.

I have pushed 3 commits: The first one reverts the previous one, the next creates the test and the last reapplies the fix.

You can checkout 41bcacc to verify it was happening ;)


import static org.junit.Assert.*;

public class ArrowBufTest {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you rename this to TestArrowBuf?

@icexelloss
Copy link
Contributor

Thanks @gortiz for catching this.

This wasn't covered by any test because the code path is only used by VarBinaryVector and there is no java unit test for VarBinaryVector.

@gortiz can you give me write permission to your branch? I'd like to add a test for VarBinaryVector as well. (If you are willing to add the test it'd be awesome too!)

@gortiz
Copy link
Contributor Author

gortiz commented Aug 31, 2017

@icexelloss I'm not sure if there is other ways to give you write permission, but I've added you and @wesm as collaborators on my fork. That should be enough

@icexelloss
Copy link
Contributor

@gortiz Thanks. Actually there is test for VarBinaryVector but doesn't cover this code path. I will add test in TestValueVector.java.

@icexelloss
Copy link
Contributor

@gortiz I pushed a change that adds more vector tests to your branch. Can you rename ArrowBuf test and add license to the file?

Otherwise LGTM

@icexelloss
Copy link
Contributor

@gortiz Can you remove the old ArrowBufTest.java file?

@icexelloss
Copy link
Contributor

Otherwise LGTM

@gortiz
Copy link
Contributor Author

gortiz commented Sep 1, 2017

Done. My bad!

Copy link
Member

@wesm wesm left a comment

Choose a reason for hiding this comment

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

+1. thanks @icexelloss for reviewing!

@asfgit asfgit closed this in 28553b4 Sep 1, 2017
@wesm
Copy link
Member

wesm commented Sep 1, 2017

thank you @gortiz for your contribution!

@gortiz
Copy link
Contributor Author

gortiz commented Sep 4, 2017

Happy to help! I hope my employer decides to integrate Arrow in our project, in which case I will be pushing to contribute with more PRs!

pribor pushed a commit to GlobalWebIndex/arrow that referenced this pull request Oct 24, 2025
…ed ByteBuffers

There is a small bug on ArrowBuf at line 750. It says:
`udle.setBytes(index + offset, buf);`

But it should say:
`udle.setBytes(index + offset, newBuf);`

There is a wraparound: You can call the method with the already sliced buffer.

Author: Gonzalo Ortiz <golthiryus@gmail.com>
Author: Li Jin <ice.xelloss@gmail.com>

Closes apache#1022 from gortiz/master and squashes the following commits:

cdffbcc [Gonzalo Ortiz] Removed the old ArrowBufTest (which was renamed as TestArrowBuf)
d8aa00f [Gonzalo Ortiz] Renamed to ArrowBufTest to TestArrowBuf
1968a98 [Gonzalo Ortiz] Added license header
aa6c457 [Li Jin] Add more tests for NullableVarChar and NullableVarBinary
e65e380 [Gonzalo Ortiz] ARROW-1443 Reapplying the bug fix
41bcacc [Gonzalo Ortiz] ARROW-1443 Added a test to verify the bug
f70ceff [Gonzalo Ortiz] ARROW-1443 Reverted the previous commit to reproduce the bug
cef014f [Gonzalo Ortiz] [Java] Fixed a small bug on ArrowBuf.setBytes with unsliced ByteBuffers
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.

3 participants