openjdk version "17.0.11" 2024-04-16
OpenJDK Runtime Environment Temurin-17.0.11+9 (build 17.0.11+9)
OpenJDK 64-Bit Server VM Temurin-17.0.11+9 (build 17.0.11+9, mixed mode)
jdk 21 :
openjdk version "21.0.3" 2024-04-16 LTS
OpenJDK Runtime Environment Temurin-21.0.3+9 (build 21.0.3+9-LTS)
OpenJDK 64-Bit Server VM Temurin-21.0.3+9 (build 21.0.3+9-LTS, mixed mode)
version :0.127.19
Steps to reproduce
Hello,
Trying to copy a file from a GCP bucket to my application, I noticed that using the method Path#copy(Path, Path, CopyOption...) is throwing an exception with java 21, although it was working well with java 17.
Here is an example of code :
public static void main(String[] args) {
try {
Path bucketSource = Paths.get(new URI("gs://my-bucket/file.txt"));
//copy with FileOutputStream
Files.copy(bucketSource, new FileOutputStream("./target/fos.txt"));
System.out.println("copy with FileOutputStream : ok");
//copy with Path
Files.copy(bucketSource, Paths.get("./target/path.txt"));
System.out.println("copy with Path : ok");
} catch (Exception ex) {
ex.printStackTrace();
}
}
Execution with java 17 :
/Users/ALEXANDRE/.sdkman/candidates/java/17.0.11-tem/bin/java ...
copy with FileOutputStream : ok
copy with Path : ok
Process finished with exit code 0
Execution with java 21 :
/Users/ALEXANDRE/.sdkman/candidates/java/21.0.3-tem/bin/java ...
copy with FileOutputStream : ok
java.lang.UnsupportedOperationException: PosixFileAttributeView
at com.google.cloud.storage.contrib.nio.CloudStorageFileSystemProvider.getFileAttributeView(CloudStorageFileSystemProvider.java:1023)
at java.base/java.nio.file.Files.getFileAttributeView(Files.java:1790)
at java.base/java.nio.file.CopyMoveHelper.copyToForeignTarget(CopyMoveHelper.java:110)
at java.base/java.nio.file.Files.copy(Files.java:1307)
at Stat.main(Stat.java:19)
Process finished with exit code 0
Environment details
OS type and version :
Java version :
version :
0.127.19
Steps to reproduce
Hello, Trying to copy a file from a GCP bucket to my application, I noticed that using the method
Path#copy(Path, Path, CopyOption...)
is throwing an exception with java 21, although it was working well with java 17. Here is an example of code :Execution with java 17 :
Execution with java 21 :
Thanks!