Skip to content

Commit

Permalink
Fix for #1401: backport thread-safety change
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-milles committed Oct 4, 2022
1 parent 8acdec8 commit 85300d0
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 58 deletions.
Expand Up @@ -14,6 +14,7 @@
import java.io.IOException;
import java.net.URI;
import java.nio.file.DirectoryStream;
import java.nio.file.FileSystemAlreadyExistsException;
import java.nio.file.FileSystemNotFoundException;
import java.nio.file.FileSystems;
import java.nio.file.FileVisitResult;
Expand Down Expand Up @@ -120,7 +121,11 @@ public void initialize() throws IOException {
}
if (this.fs == null) {
HashMap<String, ?> env = new HashMap<>();
this.fs = FileSystems.newFileSystem(uri, env);
try {
this.fs = FileSystems.newFileSystem(uri, env);
} catch (FileSystemAlreadyExistsException e) {
this.fs = FileSystems.getFileSystem(uri);
}
}
this.releasePath = this.fs.getPath("/"); //$NON-NLS-1$
if (!Files.exists(this.fs.getPath(this.releaseInHex))) {
Expand All @@ -130,7 +135,7 @@ public void initialize() throws IOException {
}
@Override
public void loadModules() {
// Modules below level 8 are not dealt with here. Leave it to ClasspathJrt
// Modules below level 9 are not dealt with here. Leave it to ClasspathJrt
if (this.jdklevel <= ClassFileConstants.JDK1_8) {
super.loadModules();
return;
Expand Down Expand Up @@ -191,7 +196,7 @@ public FileVisitResult postVisitDirectory(java.nio.file.Path dir, IOException ex
}
@Override
void acceptModule(ClassFileReader reader, Map<String, IModule> cache) {
// Modules below level 8 are not dealt with here. Leave it to ClasspathJrt
// Modules below level 9 are not dealt with here. Leave it to ClasspathJrt
if (this.jdklevel <= ClassFileConstants.JDK1_8) {
super.acceptModule(reader, cache);
return;
Expand Down Expand Up @@ -259,15 +264,6 @@ public FileVisitResult postVisitDirectory(java.nio.file.Path dir, IOException ex
return singletonModuleNameIf(this.packageCache.contains(qualifiedPackageName));
}
@Override
public void reset() {
try {
super.reset();
this.fs.close();
} catch (IOException e) {
// Move on
}
}
@Override
public String toString() {
return "Classpath for JEP 247 for JDK " + this.file.getPath(); //$NON-NLS-1$
}
Expand Down
Expand Up @@ -14,6 +14,7 @@
import java.io.IOException;
import java.net.URI;
import java.nio.file.DirectoryStream;
import java.nio.file.FileSystemAlreadyExistsException;
import java.nio.file.FileSystemNotFoundException;
import java.nio.file.FileSystems;
import java.nio.file.FileVisitResult;
Expand Down Expand Up @@ -120,7 +121,11 @@ public void initialize() throws IOException {
}
if (this.fs == null) {
HashMap<String, ?> env = new HashMap<>();
this.fs = FileSystems.newFileSystem(uri, env);
try {
this.fs = FileSystems.newFileSystem(uri, env);
} catch (FileSystemAlreadyExistsException e) {
this.fs = FileSystems.getFileSystem(uri);
}
}
this.releasePath = this.fs.getPath("/"); //$NON-NLS-1$
if (!Files.exists(this.fs.getPath(this.releaseInHex))) {
Expand All @@ -130,7 +135,7 @@ public void initialize() throws IOException {
}
@Override
public void loadModules() {
// Modules below level 8 are not dealt with here. Leave it to ClasspathJrt
// Modules below level 9 are not dealt with here. Leave it to ClasspathJrt
if (this.jdklevel <= ClassFileConstants.JDK1_8) {
super.loadModules();
return;
Expand Down Expand Up @@ -191,7 +196,7 @@ public FileVisitResult postVisitDirectory(java.nio.file.Path dir, IOException ex
}
@Override
void acceptModule(ClassFileReader reader, Map<String, IModule> cache) {
// Modules below level 8 are not dealt with here. Leave it to ClasspathJrt
// Modules below level 9 are not dealt with here. Leave it to ClasspathJrt
if (this.jdklevel <= ClassFileConstants.JDK1_8) {
super.acceptModule(reader, cache);
return;
Expand Down Expand Up @@ -259,15 +264,6 @@ public FileVisitResult postVisitDirectory(java.nio.file.Path dir, IOException ex
return singletonModuleNameIf(this.packageCache.contains(qualifiedPackageName));
}
@Override
public void reset() {
try {
super.reset();
this.fs.close();
} catch (IOException e) {
// Move on
}
}
@Override
public String toString() {
return "Classpath for JEP 247 for JDK " + this.file.getPath(); //$NON-NLS-1$
}
Expand Down
Expand Up @@ -14,6 +14,7 @@
import java.io.IOException;
import java.net.URI;
import java.nio.file.DirectoryStream;
import java.nio.file.FileSystemAlreadyExistsException;
import java.nio.file.FileSystemNotFoundException;
import java.nio.file.FileSystems;
import java.nio.file.FileVisitResult;
Expand Down Expand Up @@ -120,7 +121,11 @@ public void initialize() throws IOException {
}
if (this.fs == null) {
HashMap<String, ?> env = new HashMap<>();
this.fs = FileSystems.newFileSystem(uri, env);
try {
this.fs = FileSystems.newFileSystem(uri, env);
} catch (FileSystemAlreadyExistsException e) {
this.fs = FileSystems.getFileSystem(uri);
}
}
this.releasePath = this.fs.getPath("/"); //$NON-NLS-1$
if (!Files.exists(this.fs.getPath(this.releaseInHex))) {
Expand All @@ -130,7 +135,7 @@ public void initialize() throws IOException {
}
@Override
public void loadModules() {
// Modules below level 8 are not dealt with here. Leave it to ClasspathJrt
// Modules below level 9 are not dealt with here. Leave it to ClasspathJrt
if (this.jdklevel <= ClassFileConstants.JDK1_8) {
super.loadModules();
return;
Expand Down Expand Up @@ -191,7 +196,7 @@ public FileVisitResult postVisitDirectory(java.nio.file.Path dir, IOException ex
}
@Override
void acceptModule(ClassFileReader reader, Map<String, IModule> cache) {
// Modules below level 8 are not dealt with here. Leave it to ClasspathJrt
// Modules below level 9 are not dealt with here. Leave it to ClasspathJrt
if (this.jdklevel <= ClassFileConstants.JDK1_8) {
super.acceptModule(reader, cache);
return;
Expand Down Expand Up @@ -262,15 +267,6 @@ public FileVisitResult postVisitDirectory(java.nio.file.Path dir, IOException ex
return singletonModuleNameIf(this.packageCache.contains(qualifiedPackageName));
}
@Override
public void reset() {
try {
super.reset();
this.fs.close();
} catch (IOException e) {
// Move on
}
}
@Override
public String toString() {
return "Classpath for JEP 247 for JDK " + this.file.getPath(); //$NON-NLS-1$
}
Expand Down
Expand Up @@ -14,6 +14,7 @@
import java.io.IOException;
import java.net.URI;
import java.nio.file.DirectoryStream;
import java.nio.file.FileSystemAlreadyExistsException;
import java.nio.file.FileSystemNotFoundException;
import java.nio.file.FileSystems;
import java.nio.file.FileVisitResult;
Expand Down Expand Up @@ -120,7 +121,11 @@ public void initialize() throws IOException {
}
if (this.fs == null) {
HashMap<String, ?> env = new HashMap<>();
this.fs = FileSystems.newFileSystem(uri, env);
try {
this.fs = FileSystems.newFileSystem(uri, env);
} catch (FileSystemAlreadyExistsException e) {
this.fs = FileSystems.getFileSystem(uri);
}
}
this.releasePath = this.fs.getPath("/"); //$NON-NLS-1$
if (!Files.exists(this.fs.getPath(this.releaseInHex))) {
Expand All @@ -130,7 +135,7 @@ public void initialize() throws IOException {
}
@Override
public void loadModules() {
// Modules below level 8 are not dealt with here. Leave it to ClasspathJrt
// Modules below level 9 are not dealt with here. Leave it to ClasspathJrt
if (this.jdklevel <= ClassFileConstants.JDK1_8) {
super.loadModules();
return;
Expand Down Expand Up @@ -191,7 +196,7 @@ public FileVisitResult postVisitDirectory(java.nio.file.Path dir, IOException ex
}
@Override
void acceptModule(ClassFileReader reader, Map<String, IModule> cache) {
// Modules below level 8 are not dealt with here. Leave it to ClasspathJrt
// Modules below level 9 are not dealt with here. Leave it to ClasspathJrt
if (this.jdklevel <= ClassFileConstants.JDK1_8) {
super.acceptModule(reader, cache);
return;
Expand Down Expand Up @@ -262,15 +267,6 @@ public FileVisitResult postVisitDirectory(java.nio.file.Path dir, IOException ex
return singletonModuleNameIf(this.packageCache.contains(qualifiedPackageName));
}
@Override
public void reset() {
try {
super.reset();
this.fs.close();
} catch (IOException e) {
// Move on
}
}
@Override
public String toString() {
return "Classpath for JEP 247 for JDK " + this.file.getPath(); //$NON-NLS-1$
}
Expand Down
Expand Up @@ -14,6 +14,7 @@
import java.io.IOException;
import java.net.URI;
import java.nio.file.DirectoryStream;
import java.nio.file.FileSystemAlreadyExistsException;
import java.nio.file.FileSystemNotFoundException;
import java.nio.file.FileSystems;
import java.nio.file.FileVisitResult;
Expand Down Expand Up @@ -120,7 +121,11 @@ public void initialize() throws IOException {
}
if (this.fs == null) {
HashMap<String, ?> env = new HashMap<>();
this.fs = FileSystems.newFileSystem(uri, env);
try {
this.fs = FileSystems.newFileSystem(uri, env);
} catch (FileSystemAlreadyExistsException e) {
this.fs = FileSystems.getFileSystem(uri);
}
}
this.releasePath = this.fs.getPath("/"); //$NON-NLS-1$
if (!Files.exists(this.fs.getPath(this.releaseInHex))) {
Expand Down Expand Up @@ -262,15 +267,6 @@ public FileVisitResult postVisitDirectory(java.nio.file.Path dir, IOException ex
return singletonModuleNameIf(this.packageCache.contains(qualifiedPackageName));
}
@Override
public void reset() {
try {
super.reset();
this.fs.close();
} catch (IOException e) {
// Move on
}
}
@Override
public String toString() {
return "Classpath for JEP 247 for JDK " + this.file.getPath(); //$NON-NLS-1$
}
Expand Down

0 comments on commit 85300d0

Please sign in to comment.