Skip to content

PutObject with IfMatch condition on etag succeeds instead of throwing NoSuchKeyException #2502

@yankeenjg

Description

@yankeenjg

Example Test --

The following test succeeds on S3 (the S3Exception status code is 404), but fails with the AdobeS3Mock. In particular, the put object succeeds.

public class Example {

    private static final String BUCKET_NAME = "...";

    @Override
    public void WhenObjectNotExistsThenPutObjectFailsWithIfMatch() {
        PutObjectRequest request = PutObjectRequest.builder()
            .bucket(BUCKET_NAME)
            .ifMatch("abcd")
            .key(UUID.randomUUID().toString())
            .build();

        try {
            s3.putObject(request, RequestBody.fromBytes("abcd"));
            fail();
        } catch (S3Exception e) {
            assertTrue(e.statusCode() == 404 || e.statusCode() == 412);
        }
    }

}

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions