You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There's an inconsistency between this implementation's interpretation of delimiters and the AWS S3 api, as well as what seems to be a bug or two.
(AWS) When making a list_objects_v2 query, if there's an empty delimiter specified, AWS ignores it, returning the same as were there no delimiter specified (I've tested this against AWS).
(S3 Mock) This mock has inconsistent behaviour. If the prefix is empty, this mock returns all keys separately within the contents. If the prefix is not empty, this mock treats all keys matching that prefix as containing the delimiter, and combines them into a single CommonPrefixes (that is the Prefix within the user request).
(AWS) When making a list_objects_v2 query, if the delimiter is non-empty and occurs at index zero of the key, AWS splits this into a separate CommonPrefixes entry. Likewise, if it occurs at an index greater than zero, this is split into another separate CommonPrefixes entry (I've not tested this against AWS, but guessing).
(S3 Mock) When the delimiter is non-empty and occurs at index zero of the key, this mock doesn't separate this into a common prefix, instead outputting the full key (even if the delimiter occurs multiple times within the key). If the delimiter occurs at an index greater than zero, this case is handled correctly.
This implementation only checks for the delimiter being null:
This function normalizes the prefix then tests for the index of the above delimiter in each key, after the prefix.
For an empty delimiter, as the empty string is present in any string this will return a non-negative number for any key containing the prefix (where -1 indicates the string isn't present). Hence it's necessary to change the above conditional to use StringUtils.isEmpty. The index returned will be the index after the prefix, and the same for every key containing the prefix meaning they're all combined into the same CommonPrefixes.
Also causes another problem. In the case of a zero-length QueryPrefix, if the delimiter is at index zero, eg (delimiter '/'):
/some/object/key
/some/other/key
These keys contain the delimiter but are ignored by the above conditional, resulting in the full keys being listed. By changing the conditional to if (delimiterIndex >= 0) {
This should work correctly as indexOf returns -1 when the key is not present.
Don't mind creating a pull request, but it's been a while since I've coded in java.
The text was updated successfully, but these errors were encountered:
Also replacing the "modify incoming iterator" pattern in
FileStoreController#collapseCommonPrefixes which is an anti-pattern
and should be avoided at all costs.
Fixes#306
There's an inconsistency between this implementation's interpretation of delimiters and the AWS S3 api, as well as what seems to be a bug or two.
This implementation only checks for the delimiter being null:
S3Mock/server/src/main/java/com/adobe/testing/s3mock/FileStoreController.java
Line 287 in 53dda84
Where I assume it should use
StringUtils.isEmpty
from docs which treats an empty string and a null string the same.
The above then calls the collapseCommonPrefixes function
S3Mock/server/src/main/java/com/adobe/testing/s3mock/FileStoreController.java
Lines 1043 to 1058 in 53dda84
This function normalizes the prefix then tests for the index of the above delimiter in each key, after the prefix.
For an empty delimiter, as the empty string is present in any string this will return a non-negative number for any key containing the prefix (where -1 indicates the string isn't present). Hence it's necessary to change the above conditional to use
StringUtils.isEmpty
. The index returned will be the index after the prefix, and the same for every key containing the prefix meaning they're all combined into the sameCommonPrefixes
.The above conditional
S3Mock/server/src/main/java/com/adobe/testing/s3mock/FileStoreController.java
Line 1052 in 53dda84
Also causes another problem. In the case of a zero-length
QueryPrefix
, if the delimiter is at index zero, eg (delimiter '/'):These keys contain the delimiter but are ignored by the above conditional, resulting in the full keys being listed. By changing the conditional to
if (delimiterIndex >= 0) {
This should work correctly as
indexOf
returns -1 when the key is not present.Don't mind creating a pull request, but it's been a while since I've coded in java.
The text was updated successfully, but these errors were encountered: