Open jhovell opened 6 years ago
+1, there needs to be more high-level operations on the S3 client. Eg. doesBucketExist
, doesObjectExist
, etc.
Right now, the raw S3 operations require using exceptions for non-exceptional cases.
most of the time checking for file/bucket existence buys you nothing, by the time you act on it it might already change it's state (be deleted, be created) so unwanted state exception need to be correctly handled anyway , so whats the point of checking then :)
most of the time checking for file/bucket existence buys you nothing, by the time you act on it it might already change it's state (be deleted, be created)
There are plenty of systems that simply never delete s3 objects, so once you check if it exists, that won't ever change.
Also in Java I believe it's generally frowned upon to throw/catch Exceptions for situations which are expected to happen.
I think it would be useful to have a doesObjectExist method.
This issue is still open, so I guess this feature isn't added as of now. Correct?
I was already using the doesObjectExists in the 'aws-java-sdk-s3'. I was going to the non-blocking method but since this method doesn't exist in the java 2.x, it's a spoiler. :/
To be clear: you can use the headObject method, but it's just a bit messy because you need to catch the exception if it doesn't exist.
Throwing and catching exceptions hundreds of thousands of times has a performance cost that would be good to avoid, any progress on this issue?
the exception is not thrown any way. is there a way to know if a bucket exist??
Agreed with everyone above who says we need this in the Java SDK.
Yes, I also think that controlling the flow with the exception doesn't make any sense as it's an expensive operation and rather should be an "exception". +1 for having this method.
Expected Behavior
I would expect feature parity for old 1.x methods such as
AmazonS3.doesObjectExist(bucket, key).
With the async client /CompletableFuture
it's more than a minor annoyance as the result ofS3AsyncClient.headObject(...)
is to throw a NoSuchKeyException which would logically be handled in anexceptionally(throwable -> ...)
stage but it is difficult to handle control flow such as letting other exceptions propagate.Your Environment