Skip to content

Commit 6e91c2d

Browse files
committed
Logging request conditions
1 parent 5e2dd22 commit 6e91c2d

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

server/src/main/java/com/adobe/testing/s3mock/service/ObjectService.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,29 +358,34 @@ public void verifyObjectMatching(
358358

359359
var setModifiedSince = ifModifiedSince != null && !ifModifiedSince.isEmpty();
360360
if (setModifiedSince && ifModifiedSince.get(0).isAfter(lastModified)) {
361+
LOG.debug("Object {} not modified since {}", s3ObjectMetadata.key(), ifModifiedSince.get(0));
361362
throw NOT_MODIFIED;
362363
}
363364

364365
var setMatch = match != null && !match.isEmpty();
365366
if (setMatch) {
366367
if (match.contains(WILDCARD_ETAG) || match.contains(WILDCARD) || match.contains(etag)) {
367-
//request cares only that the object exists
368+
//request cares only that the object exists or that the etag matches.
369+
LOG.debug("Object {} exists", s3ObjectMetadata.key());
368370
return;
369371
} else if (!match.contains(etag)) {
372+
LOG.debug("Object {} does not match etag {}", s3ObjectMetadata.key(), etag);
370373
throw PRECONDITION_FAILED;
371374
}
372375
}
373376

374377
var setUnmodifiedSince = ifUnmodifiedSince != null && !ifUnmodifiedSince.isEmpty();
375378
if (setUnmodifiedSince && ifUnmodifiedSince.get(0).isBefore(lastModified)) {
379+
LOG.debug("Object {} modified since {}", s3ObjectMetadata.key(), ifUnmodifiedSince.get(0));
376380
throw PRECONDITION_FAILED;
377381
}
378382

379383
var setNoneMatch = noneMatch != null && !noneMatch.isEmpty();
380384
if (setNoneMatch
381385
&& (noneMatch.contains(WILDCARD_ETAG) || noneMatch.contains(WILDCARD) || noneMatch.contains(etag))
382386
) {
383-
//request cares only that the object DOES NOT exist.
387+
//request cares only that the object etag does not match.
388+
LOG.debug("Object {} does not exist", s3ObjectMetadata.key());
384389
throw NOT_MODIFIED;
385390
}
386391
}

0 commit comments

Comments
 (0)