rishabhdaim commented on code in PR #2558:
URL: https://github.com/apache/jackrabbit-oak/pull/2558#discussion_r2416473470


##########
oak-blob-cloud/src/main/java/org/apache/jackrabbit/oak/blob/cloud/s3/S3Backend.java:
##########
@@ -391,21 +395,10 @@ public boolean exists(DataIdentifier identifier) throws 
DataStoreException {
         ClassLoader contextClassLoader = 
Thread.currentThread().getContextClassLoader();
         try {
             
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
-            ObjectMetadata objectMetaData = 
s3service.getObjectMetadata(s3ReqDecorator.decorate(new 
GetObjectMetadataRequest(bucket, key)));
-            if (objectMetaData != null) {
-                LOG.trace("exists [{}]: [true] took [{}] ms.",
-                    identifier, (System.currentTimeMillis() - start) );
-                return true;
-            }
-            return false;
-        } catch (AmazonServiceException e) {
-            if (e.getStatusCode() == 404 || e.getStatusCode() == 403) {
-                LOG.debug("exists [{}]: [false] took [{}] ms.",
-                    identifier, (System.currentTimeMillis() - start) );
-                return false;
-            }
-            throw new DataStoreException(
-                "Error occured to getObjectMetadata for key [" + 
identifier.toString() + "]", e);
+            return Utils.objectExists(s3Client, bucket, key, s3ReqDecorator);

Review Comment:
   This was added to avoid duplicate code.
   It was becoming cumbersome for me to update the same request at different 
places, and also led to many errors once forgot.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to