You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2016/01/08 08:23:17 UTC
ignite git commit: IGNITE-2342: Set correct classlader before calling
FileSystem.get().
Repository: ignite
Updated Branches:
refs/heads/ignite-1.5.2 c786820dd -> 6ab4ce246
IGNITE-2342: Set correct classlader before calling FileSystem.get().
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/6ab4ce24
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/6ab4ce24
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/6ab4ce24
Branch: refs/heads/ignite-1.5.2
Commit: 6ab4ce246316442fa4295f9941c372fea70c24ef
Parents: c786820
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Fri Jan 8 10:23:55 2016 +0400
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Fri Jan 8 10:23:55 2016 +0400
----------------------------------------------------------------------
.../hadoop/fs/BasicHadoopFileSystemFactory.java | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/6ab4ce24/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/BasicHadoopFileSystemFactory.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/BasicHadoopFileSystemFactory.java b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/BasicHadoopFileSystemFactory.java
index 1e2bbf2..c791e9a 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/BasicHadoopFileSystemFactory.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/BasicHadoopFileSystemFactory.java
@@ -80,7 +80,24 @@ public class BasicHadoopFileSystemFactory implements HadoopFileSystemFactory, Ex
assert cfg != null;
try {
- return FileSystem.get(fullUri, cfg, usrName);
+ // FileSystem.get() might delegate to ServiceLoader to get the list of file system implementation.
+ // And ServiceLoader is known to be sensitive to context classloader. Therefore, we change context
+ // classloader to classloader of current class to avoid strange class-cast-exceptions.
+ ClassLoader ctxClsLdr = Thread.currentThread().getContextClassLoader();
+ ClassLoader clsLdr = getClass().getClassLoader();
+
+ if (ctxClsLdr == clsLdr)
+ return FileSystem.get(fullUri, cfg, usrName);
+ else {
+ Thread.currentThread().setContextClassLoader(clsLdr);
+
+ try {
+ return FileSystem.get(fullUri, cfg, usrName);
+ }
+ finally {
+ Thread.currentThread().setContextClassLoader(ctxClsLdr);
+ }
+ }
}
catch (InterruptedException e) {
Thread.currentThread().interrupt();