forked from neo4j-contrib/neo4j-apoc-procedures
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SXnVeQi9] change ApocStreamHandlerFactory to a service provider to a…
…void deadlock on startup (neo4j-contrib#210)
- Loading branch information
1 parent
3a01fe6
commit 81c777c
Showing
7 changed files
with
118 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 7 additions & 5 deletions
12
common/src/main/java/apoc/util/ApocUrlStreamHandlerFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
package apoc.util; | ||
|
||
import java.net.URLStreamHandler; | ||
import java.net.URLStreamHandlerFactory; | ||
import java.net.spi.URLStreamHandlerProvider; | ||
|
||
public class ApocUrlStreamHandlerFactory implements URLStreamHandlerFactory { | ||
|
||
|
||
public class ApocUrlStreamHandlerFactory extends URLStreamHandlerProvider | ||
{ | ||
|
||
@Override | ||
public URLStreamHandler createURLStreamHandler(String protocol) { | ||
FileUtils.SupportedProtocols supportedProtocol = FileUtils.SupportedProtocols.of(protocol); | ||
return supportedProtocol == null ? null : supportedProtocol.createURLStreamHandler(); | ||
SupportedProtocols supportedProtocol = FileUtils.of(protocol); | ||
return supportedProtocol == null ? null : FileUtils.createURLStreamHandler(supportedProtocol); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package apoc.util; | ||
|
||
public enum SupportedProtocols | ||
{ | ||
http(true, null), | ||
https(true, null), | ||
ftp(true, null), | ||
s3(Util.classExists("com.amazonaws.services.s3.AmazonS3"), | ||
"apoc.util.s3.S3UrlStreamHandlerFactory"), | ||
gs(Util.classExists("com.google.cloud.storage.Storage"), | ||
"apoc.util.google.cloud.GCStorageURLStreamHandlerFactory"), | ||
hdfs(Util.classExists("org.apache.hadoop.fs.FileSystem"), | ||
"org.apache.hadoop.fs.FsUrlStreamHandlerFactory"), | ||
file(true, null); | ||
|
||
private final boolean enabled; | ||
|
||
private final String urlStreamHandlerClassName; | ||
|
||
SupportedProtocols(boolean enabled, String urlStreamHandlerClassName) { | ||
this.enabled = enabled; | ||
this.urlStreamHandlerClassName = urlStreamHandlerClassName; | ||
} | ||
|
||
public boolean isEnabled() { | ||
return enabled; | ||
} | ||
|
||
String getUrlStreamHandlerClassName() { | ||
return urlStreamHandlerClassName; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
common/src/main/resources/META-INF/services/java.net.spi.URLStreamHandlerProvider
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
apoc.util.ApocUrlStreamHandlerFactory |