-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Empty listing Bug Fix and Other Pending Changes #144
Changes from 4 commits
bdbf05c
18a1510
c1eee6a
1bf0d36
71e912c
7c59b28
3f5b28d
95c2d34
2327020
3be06a0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -647,12 +647,10 @@ public AbfsRestOperation listPath(final String relativePath, final boolean recur | |
abfsUriQueryBuilder.addQuery(QUERY_PARAM_COMP, LIST); | ||
abfsUriQueryBuilder.addQuery(QUERY_PARAM_INCLUDE, METADATA); | ||
abfsUriQueryBuilder.addQuery(QUERY_PARAM_PREFIX, getDirectoryQueryParameter(relativePath)); | ||
abfsUriQueryBuilder.addQuery(QUERY_PARAM_MARKER, continuation); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was a redundant check. Same check is already added in AbfsUriQueryBuilder.java
|
||
if (!recursive) { | ||
abfsUriQueryBuilder.addQuery(QUERY_PARAM_DELIMITER, FORWARD_SLASH); | ||
} | ||
if (continuation != null) { | ||
abfsUriQueryBuilder.addQuery(QUERY_PARAM_MARKER, continuation); | ||
} | ||
abfsUriQueryBuilder.addQuery(QUERY_PARAM_MAX_RESULTS, String.valueOf(listMaxResults)); | ||
appendSASTokenToQuery(relativePath, SASTokenProvider.LIST_BLOB_OPERATION, abfsUriQueryBuilder); | ||
|
||
|
@@ -714,12 +712,6 @@ private void fixAtomicEntriesInListResults(final AbfsRestOperation op, | |
listResultSchema.withPaths(filteredEntries); | ||
} | ||
|
||
private boolean isEmptyListResults(AbfsHttpOperation result) { | ||
return result != null && result.getStatusCode() == HTTP_OK && | ||
result.getListResultSchema() != null && | ||
result.getListResultSchema().paths().isEmpty(); | ||
} | ||
|
||
/** | ||
* Get Rest Operation for API <a href = https://learn.microsoft.com/en-us/rest/api/storageservices/lease-blob></a>. | ||
* @param path on which lease has to be acquired. | ||
|
@@ -1789,13 +1781,24 @@ private static String decodeMetadataAttribute(String encoded) | |
return encoded == null ? null : | ||
java.net.URLDecoder.decode(encoded, StandardCharsets.UTF_8.name()); | ||
} | ||
|
||
private boolean isNonEmptyListing(String path, | ||
TracingContext tracingContext) throws AzureBlobFileSystemException { | ||
AbfsRestOperation listOp = listPath(path, false, 1, null, tracingContext, false); | ||
BlobListResultSchema listResultSchema = | ||
(BlobListResultSchema) listOp.getResult().getListResultSchema(); | ||
return listResultSchema.paths() != null && !listResultSchema.paths() | ||
.isEmpty(); | ||
return !isEmptyListResults(listOp.getResult()); | ||
} | ||
|
||
private boolean isEmptyListResults(AbfsHttpOperation result) { | ||
boolean isEmptyList = result != null && result.getStatusCode() == HTTP_OK && // List Call was successful | ||
result.getListResultSchema() != null && // Parsing of list response was successful | ||
result.getListResultSchema().paths().isEmpty() && // No paths were returned | ||
result.getListResultSchema() instanceof BlobListResultSchema && // It is safe to typecast to BlobListResultSchema | ||
((BlobListResultSchema) result.getListResultSchema()).getNextMarker() == null; // No continuation token was returned | ||
if (isEmptyList) { | ||
LOG.debug("List call returned empty results without any continuation token."); | ||
return true; | ||
} else if (result != null && !(result.getListResultSchema() instanceof BlobListResultSchema)) { | ||
throw new RuntimeException("List call returned unexpected results over Blob Endpoint."); | ||
} | ||
return false; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -175,7 +175,7 @@ public static String getMaskedUrl(URL url) { | |
|
||
public static URL changeUrlFromBlobToDfs(URL url) throws InvalidUriException { | ||
try { | ||
url = new URL(url.toString().replace(ABFS_BLOB_DOMAIN_NAME, ABFS_DFS_DOMAIN_NAME)); | ||
url = new URL(url.toString().replaceFirst(ABFS_BLOB_DOMAIN_NAME, ABFS_DFS_DOMAIN_NAME)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it possible to have more than one .blob. in the url ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated code as per the discussion offline |
||
} catch (MalformedURLException ex) { | ||
throw new InvalidUriException(url.toString()); | ||
} | ||
|
@@ -184,7 +184,7 @@ public static URL changeUrlFromBlobToDfs(URL url) throws InvalidUriException { | |
|
||
public static URL changeUrlFromDfsToBlob(URL url) throws InvalidUriException { | ||
try { | ||
url = new URL(url.toString().replace(ABFS_DFS_DOMAIN_NAME, ABFS_BLOB_DOMAIN_NAME)); | ||
url = new URL(url.toString().replaceFirst(ABFS_DFS_DOMAIN_NAME, ABFS_BLOB_DOMAIN_NAME)); | ||
} catch (MalformedURLException ex) { | ||
throw new InvalidUriException(url.toString()); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,9 @@ | |
import java.io.IOException; | ||
import java.net.URI; | ||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.Hashtable; | ||
import java.util.Iterator; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.UUID; | ||
|
@@ -672,7 +674,7 @@ protected void assumeBlobServiceType() { | |
*/ | ||
protected void assertPathDns(Path path) { | ||
String expectedDns = getAbfsServiceType() == AbfsServiceType.BLOB | ||
? ABFS_BLOB_DOMAIN_NAME : ABFS_DFS_DOMAIN_NAME; | ||
? ABFS_BLOB_DOMAIN_NAME : ABFS_DFS_DOMAIN_NAME;; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. double semicolon There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Taken |
||
Assertions.assertThat(path.toString()).contains(expectedDns); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we removing the close() method call here ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We needed close because we were checking it after creating filesystem.
Now we are checking it before creating file system and failing, so no need to close.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is a significant change will trigger a CI.
We can wait for CI results before merging this.