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

Move results in IndexOutOfBounds Exception #333

Open
HendrikHoetker opened this issue Dec 16, 2021 · 3 comments
Open

Move results in IndexOutOfBounds Exception #333

HendrikHoetker opened this issue Dec 16, 2021 · 3 comments

Comments

@HendrikHoetker
Copy link

I am using the Artifactory Client API in my java application:

@Override public boolean rename(String oldPath, String newPath) {
    try {
        artifactory.repository(repository).file(oldPath).move(repository, newPath);
    } catch (Exception e) {
        e.printStackTrace();
        return false;
    }

    return isFile(newPath);
}

I am sure I am logged in correctly via username/password as other functions work properly

The file to be renamed is a simple text file (32bytes) which is confirmed to exists and is a valid file.
Renaming the same file via Web User Interface with same name works fine.

Resulting exception:

java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0
at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)
at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:248)
at java.base/java.util.Objects.checkIndex(Objects.java:372)
at java.base/java.util.ArrayList.get(ArrayList.java:459)
at java_util_List$get.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:128)
at org.jfrog.artifactory.client.impl.ItemHandleImpl.moveOrCopy(ItemHandleImpl.groovy:153)
at org.jfrog.artifactory.client.impl.ItemHandleImpl.move(ItemHandleImpl.groovy:133)

@eyalbe4
Copy link
Contributor

eyalbe4 commented Dec 17, 2021

Thanks for reporting this @HendrikHoetker.
Since artifactory-client-java uses the underlying REST API of Artifactory, it's worth checking if the REST API works properly for you.
If the issue is with the artifactory-client-java code, we'd gladly accept a pull request with the fix.

@jonesbusy
Copy link
Contributor

Hi,

I just go the same issue.

My code is as simple as

ItemHandle sourceItem = artifactory.repository(config.getRepository()).folder(sourcePath);
sourceItem.move(config.getRepository(), targetPath);
java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0
...
at org.jfrog.artifactory.client.impl.ItemHandleImpl.moveOrCopy(ItemHandleImpl.groovy:153)
at org.jfrog.artifactory.client.impl.ItemHandleImpl.move(ItemHandleImpl.groovy:133)
...

@jonesbusy
Copy link
Contributor

jonesbusy commented Mar 17, 2024

This fail because of this check (https://github.com/jfrog/artifactory-client-java/blob/e39db33c2d8b87134bac115ae43a1408ee1964b6/services/src/main/groovy/org/jfrog/artifactory/client/impl/ItemHandleImpl.groovy#L153C1-L155C10)

        if (!message.getMessages().get(0).getLevel().contains('INFO')) {
            throw new CopyMoveException(message)
        }

Looks message.getMessages() is empty for some reason.

I would like to submit a patch to check check that the messages are notEmpty before checking the first element

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

No branches or pull requests

3 participants