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

NullPointerException accessing Item.lastModified() #1606

Closed
hwaite opened this issue Dec 22, 2024 · 5 comments
Closed

NullPointerException accessing Item.lastModified() #1606

hwaite opened this issue Dec 22, 2024 · 5 comments
Labels

Comments

@hwaite
Copy link
Contributor

hwaite commented Dec 22, 2024

See #1605. NullPointerException on accessing io.minio.messages.Item.lastModified() against item retrieved from io.minio.MinioClient.listObjects(io.minio.ListObjectsArgs). Error occurs if the object prefix represents a pseudo-folder (i.e. there are object keys that follow prefix with a slash):

final String bucket = "buck";
try (
    MinioClient client = MinioClient.builder()
        .endpoint("%s:%s".formatted(MINIO_HOST, MINIO_PORT))
        .credentials(MINIO_USERNAME, MINIO_PASSWORD)
        .build()
) {
    client.makeBucket(
        MakeBucketArgs.builder()
            .bucket(bucket)
            .build()
    );

    for (String str : List.of("foo/bar", "foo/car")) {
        final long size = str.length();
        client.putObject(
            PutObjectArgs.builder()
                .bucket(bucket)
                .object(str)
                .stream(
                    new ByteArrayInputStream(str.getBytes(StandardCharsets.UTF_8)),
                    size,
                    -1
                )
                .build()

        );
    }

    for (
        Result<Item> r :
        client.listObjects(
            ListObjectsArgs.builder()
                .bucket(bucket)
                .prefix("foo")
                .build()
        )
    ) {
        System.out.println(r.get().lastModified());
    }
}
@balamurugana
Copy link
Member

Please share the object storage server detail

@hwaite
Copy link
Contributor Author

hwaite commented Dec 22, 2024

Nothing special:

services:
  minio:
    image: 'minio/minio:latest'
    hostname: minio
    container_name: minio-test
    ports:
      - '9000:9000'
      - '9001:9001'
    volumes:
      - minio-data:/data
    environment:
      MINIO_ACCESS_KEY: minio
      MINIO_SECRET_KEY: minio123
    command: server --console-address ":9001" /data

volumes:
  minio-data:
    driver: local

@balamurugana
Copy link
Member

Looks like a server bug @harshavardhana

@minio-trusted
Copy link
Contributor

@balamurugana this is a non-recursive list, the common-prefix is being returned LastModified has no value for CommonPrefixes - minio-java must not fail here.

@harshavardhana
Copy link
Member

fixed via #1605

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants