mirror of https://github.com/apache/jclouds.git
Merge pull request #1194 from maginatics/rax-list-container
Work around failed metadata lookups with Rackspace
This commit is contained in:
commit
dce830adb9
|
@ -44,16 +44,28 @@ public class PublicUriForObjectInfo implements Function<ObjectInfo, URI> {
|
|||
this.cdnContainer = cdnContainer;
|
||||
}
|
||||
|
||||
private static final URI NEGATIVE_ENTRY = URI.create("http://127.0.0.1");
|
||||
|
||||
public URI apply(ObjectInfo from) {
|
||||
if (from == null)
|
||||
return null;
|
||||
try {
|
||||
return uriBuilder(cdnContainer.getUnchecked(from.getContainer()))
|
||||
.clearQuery().appendPath(from.getName()).build();
|
||||
} catch (NullPointerException e) {
|
||||
// nulls not permitted from cache loader
|
||||
String containerName = from.getContainer();
|
||||
if (containerName == null)
|
||||
return null;
|
||||
try {
|
||||
URI uri = cdnContainer.getUnchecked(containerName);
|
||||
if (uri == NEGATIVE_ENTRY) { // intentionally use reference equality
|
||||
// TODO: GetCDNMetadata.load returns null on failure cases. We use
|
||||
// a negative entry to avoid repeatedly issuing failed CDN queries.
|
||||
// The LoadingCache removes this value after its normal expiry.
|
||||
return null;
|
||||
}
|
||||
return uriBuilder(uri).clearQuery().appendPath(from.getName()).build();
|
||||
} catch (CacheLoader.InvalidCacheLoadException e) {
|
||||
// nulls not permitted from cache loader
|
||||
cdnContainer.put(containerName, NEGATIVE_ENTRY);
|
||||
return null;
|
||||
} catch (NullPointerException e) {
|
||||
// nulls not permitted from cache loader
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -48,8 +48,11 @@ public class PublicUriForObjectInfo implements Function<ObjectInfo, URI> {
|
|||
public URI apply(ObjectInfo from) {
|
||||
if (from == null)
|
||||
return null;
|
||||
String containerName = from.getContainer();
|
||||
if (containerName == null)
|
||||
return null;
|
||||
try {
|
||||
URI uri = cdnContainer.getUnchecked(from.getContainer());
|
||||
URI uri = cdnContainer.getUnchecked(containerName);
|
||||
if (uri == NEGATIVE_ENTRY) { // intentionally use reference equality
|
||||
// TODO: GetCDNMetadata.load returns null on failure cases. We use
|
||||
// a negative entry to avoid repeatedly issuing failed CDN queries.
|
||||
|
@ -59,7 +62,7 @@ public class PublicUriForObjectInfo implements Function<ObjectInfo, URI> {
|
|||
return uriBuilder(uri).clearQuery().appendPath(from.getName()).build();
|
||||
} catch (CacheLoader.InvalidCacheLoadException e) {
|
||||
// nulls not permitted from cache loader
|
||||
cdnContainer.put(from.getContainer(), NEGATIVE_ENTRY);
|
||||
cdnContainer.put(containerName, NEGATIVE_ENTRY);
|
||||
return null;
|
||||
} catch (NullPointerException e) {
|
||||
// nulls not permitted from cache loader
|
||||
|
|
Loading…
Reference in New Issue