11/*
22 * Copyright (c) 2008, 2025, Oracle and/or its affiliates. All rights reserved.
3- * Copyright (c) 2013 SAP SE. All rights reserved.
3+ * Copyright (c) 2013, 2025 SAP SE. All rights reserved.
44 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55 *
66 * This code is free software; you can redistribute it and/or modify it
@@ -52,15 +52,24 @@ AixFileStore getFileStore(UnixPath path) throws IOException {
5252 return new AixFileStore (path );
5353 }
5454
55+ static boolean supportsUserDefinedFileAttributeView (Path obj ) {
56+ try {
57+ FileStore store = Files .getFileStore (obj );
58+ return store .supportsFileAttributeView (UserDefinedFileAttributeView .class );
59+ } catch (IOException e ) {
60+ return false ;
61+ }
62+ }
63+
5564 @ Override
5665 @ SuppressWarnings ("unchecked" )
5766 public <V extends FileAttributeView > V getFileAttributeView (Path obj ,
5867 Class <V > type ,
5968 LinkOption ... options )
6069 {
6170 if (type == UserDefinedFileAttributeView .class ) {
62- return ( V ) new AixUserDefinedFileAttributeView ( UnixPath . toUnixPath ( obj ),
63- Util .followLinks (options ));
71+ return ! supportsUserDefinedFileAttributeView ( obj ) ? null :
72+ ( V ) new AixUserDefinedFileAttributeView ( UnixPath . toUnixPath ( obj ), Util .followLinks (options ));
6473 }
6574 return super .getFileAttributeView (obj , type , options );
6675 }
@@ -71,8 +80,8 @@ public DynamicFileAttributeView getFileAttributeView(Path obj,
7180 LinkOption ... options )
7281 {
7382 if (name .equals ("user" )) {
74- return new AixUserDefinedFileAttributeView ( UnixPath . toUnixPath ( obj ),
75- Util .followLinks (options ));
83+ return ! supportsUserDefinedFileAttributeView ( obj ) ? null :
84+ new AixUserDefinedFileAttributeView ( UnixPath . toUnixPath ( obj ), Util .followLinks (options ));
7685 }
7786 return super .getFileAttributeView (obj , name , options );
7887 }
0 commit comments