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

[Java] splitAndTransfer on empty ListVector should not throw IOB #39554

Closed
FiV0 opened this issue Jan 11, 2024 · 2 comments
Closed

[Java] splitAndTransfer on empty ListVector should not throw IOB #39554

FiV0 opened this issue Jan 11, 2024 · 2 comments

Comments

@FiV0
Copy link
Contributor

FiV0 commented Jan 11, 2024

The following throws with java.lang.IndexOutOfBoundsException: index: 0, length: 4 (expected: range(0, 0))

package org.apache.arrow.vector;

import org.apache.arrow.memory.RootAllocator;
import org.apache.arrow.vector.complex.ListVector;
import org.apache.arrow.vector.util.TransferPair;
import org.junit.jupiter.api.Test;

import static org.junit.Assert.assertEquals;


public class ListVectorIOBTest {

    @Test
    void shouldNotThrow()  {
        RootAllocator allocator = new RootAllocator();
        ListVector listVector = ListVector.empty("foo", allocator);

        TransferPair transferPair = listVector.getTransferPair(allocator);
        transferPair.splitAndTransfer(0,0);
        assertEquals(null, transferPair.getTo());

    }

}

Tested against the 14.0.2 tag.

I think the test condition here

if (index < 0 || index > capacity() - fieldLength) {
is not correct for index = 0 and capacity = 0.

Component(s)

Java

@FiV0 FiV0 added the Type: bug label Jan 11, 2024
@FiV0 FiV0 changed the title [Java] splitAndTransfer on empty ListVector should not throw IOE [Java] splitAndTransfer on empty ListVector should not throw IOB Jan 11, 2024
@jarohen
Copy link
Contributor

jarohen commented Mar 26, 2024

@FiV0 this might be a dupe of #30866?

@FiV0
Copy link
Contributor Author

FiV0 commented Mar 26, 2024

@jarohen yes true.

@FiV0 FiV0 closed this as completed Mar 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants