You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by ga...@apache.org on 2017/03/01 21:43:40 UTC
jclouds git commit: JCLOUDS-1218: filesystem get blob without xattrs
Repository: jclouds
Updated Branches:
refs/heads/master 8649002e0 -> fbf62437c
JCLOUDS-1218: filesystem get blob without xattrs
Some filesystems, notably Docker and Mac OS X, do not support xattr
which causes an IOException when getting a blob.
Project: http://git-wip-us.apache.org/repos/asf/jclouds/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds/commit/fbf62437
Tree: http://git-wip-us.apache.org/repos/asf/jclouds/tree/fbf62437
Diff: http://git-wip-us.apache.org/repos/asf/jclouds/diff/fbf62437
Branch: refs/heads/master
Commit: fbf62437c7e776422288564c419dc037dbd72dfa
Parents: 8649002
Author: Geert Vanheusden <ge...@aviovision.com>
Authored: Tue Feb 28 19:30:20 2017 +0100
Committer: Andrew Gaul <ga...@apache.org>
Committed: Wed Mar 1 13:41:30 2017 -0800
----------------------------------------------------------------------
.../internal/FilesystemStorageStrategyImpl.java | 56 +++++++++++---------
1 file changed, 30 insertions(+), 26 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jclouds/blob/fbf62437/apis/filesystem/src/main/java/org/jclouds/filesystem/strategy/internal/FilesystemStorageStrategyImpl.java
----------------------------------------------------------------------
diff --git a/apis/filesystem/src/main/java/org/jclouds/filesystem/strategy/internal/FilesystemStorageStrategyImpl.java b/apis/filesystem/src/main/java/org/jclouds/filesystem/strategy/internal/FilesystemStorageStrategyImpl.java
index e6209ba..577c693 100644
--- a/apis/filesystem/src/main/java/org/jclouds/filesystem/strategy/internal/FilesystemStorageStrategyImpl.java
+++ b/apis/filesystem/src/main/java/org/jclouds/filesystem/strategy/internal/FilesystemStorageStrategyImpl.java
@@ -346,33 +346,37 @@ public class FilesystemStorageStrategyImpl implements LocalStorageStrategy {
UserDefinedFileAttributeView view = getUserDefinedFileAttributeView(file.toPath());
if (view != null) {
- Set<String> attributes = ImmutableSet.copyOf(view.list());
-
- cacheControl = readStringAttributeIfPresent(view, attributes, XATTR_CACHE_CONTROL);
- contentDisposition = readStringAttributeIfPresent(view, attributes, XATTR_CONTENT_DISPOSITION);
- contentEncoding = readStringAttributeIfPresent(view, attributes, XATTR_CONTENT_ENCODING);
- contentLanguage = readStringAttributeIfPresent(view, attributes, XATTR_CONTENT_LANGUAGE);
- contentType = readStringAttributeIfPresent(view, attributes, XATTR_CONTENT_TYPE);
- if (contentType == null && autoDetectContentType) {
- contentType = probeContentType(file.toPath());
- }
- if (attributes.contains(XATTR_CONTENT_MD5)) {
- ByteBuffer buf = ByteBuffer.allocate(view.size(XATTR_CONTENT_MD5));
- view.read(XATTR_CONTENT_MD5, buf);
- hashCode = HashCode.fromBytes(buf.array());
- }
- if (attributes.contains(XATTR_EXPIRES)) {
- ByteBuffer buf = ByteBuffer.allocate(view.size(XATTR_EXPIRES));
- view.read(XATTR_EXPIRES, buf);
- buf.flip();
- expires = new Date(buf.asLongBuffer().get());
- }
- for (String attribute : attributes) {
- if (!attribute.startsWith(XATTR_USER_METADATA_PREFIX)) {
- continue;
+ try {
+ Set<String> attributes = ImmutableSet.copyOf(view.list());
+
+ cacheControl = readStringAttributeIfPresent(view, attributes, XATTR_CACHE_CONTROL);
+ contentDisposition = readStringAttributeIfPresent(view, attributes, XATTR_CONTENT_DISPOSITION);
+ contentEncoding = readStringAttributeIfPresent(view, attributes, XATTR_CONTENT_ENCODING);
+ contentLanguage = readStringAttributeIfPresent(view, attributes, XATTR_CONTENT_LANGUAGE);
+ contentType = readStringAttributeIfPresent(view, attributes, XATTR_CONTENT_TYPE);
+ if (contentType == null && autoDetectContentType) {
+ contentType = probeContentType(file.toPath());
}
- String value = readStringAttributeIfPresent(view, attributes, attribute);
- userMetadata.put(attribute.substring(XATTR_USER_METADATA_PREFIX.length()), value);
+ if (attributes.contains(XATTR_CONTENT_MD5)) {
+ ByteBuffer buf = ByteBuffer.allocate(view.size(XATTR_CONTENT_MD5));
+ view.read(XATTR_CONTENT_MD5, buf);
+ hashCode = HashCode.fromBytes(buf.array());
+ }
+ if (attributes.contains(XATTR_EXPIRES)) {
+ ByteBuffer buf = ByteBuffer.allocate(view.size(XATTR_EXPIRES));
+ view.read(XATTR_EXPIRES, buf);
+ buf.flip();
+ expires = new Date(buf.asLongBuffer().get());
+ }
+ for (String attribute : attributes) {
+ if (!attribute.startsWith(XATTR_USER_METADATA_PREFIX)) {
+ continue;
+ }
+ String value = readStringAttributeIfPresent(view, attributes, attribute);
+ userMetadata.put(attribute.substring(XATTR_USER_METADATA_PREFIX.length()), value);
+ }
+ } catch (IOException e) {
+ logger.debug("xattrs not supported on %s", file.toPath());
}
builder.payload(byteSource)