You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by la...@apache.org on 2014/05/22 19:59:11 UTC
git commit: HBASE-11110 Ability to load FilterList class is dependent
on context classloader. (Gabriel Reid)
Repository: hbase
Updated Branches:
refs/heads/0.94 7495b6a5c -> 71d197c15
HBASE-11110 Ability to load FilterList class is dependent on context classloader. (Gabriel Reid)
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/71d197c1
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/71d197c1
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/71d197c1
Branch: refs/heads/0.94
Commit: 71d197c15f17bc23c77d811459f7ea8dfb4a551a
Parents: 7495b6a
Author: Lars Hofhansl <la...@apache.org>
Authored: Thu May 22 10:56:33 2014 -0700
Committer: Lars Hofhansl <la...@apache.org>
Committed: Thu May 22 10:56:33 2014 -0700
----------------------------------------------------------------------
.../apache/hadoop/hbase/filter/FilterList.java | 22 +++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hbase/blob/71d197c1/src/main/java/org/apache/hadoop/hbase/filter/FilterList.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/hadoop/hbase/filter/FilterList.java b/src/main/java/org/apache/hadoop/hbase/filter/FilterList.java
index b9189c3..44baf39 100644
--- a/src/main/java/org/apache/hadoop/hbase/filter/FilterList.java
+++ b/src/main/java/org/apache/hadoop/hbase/filter/FilterList.java
@@ -59,7 +59,23 @@ public class FilterList implements Filter {
MUST_PASS_ONE
}
- private static final Configuration conf = HBaseConfiguration.create();
+ private static final Configuration CONF;
+ static {
+ // We don't know which thread will load this class, so we don't know what
+ // the state of the context classloader will be when this class is loaded.
+ // HBaseConfiguration.create is dependent on the state of the context
+ // classloader of the current thread, so we set it to be the classloader
+ // that was used to load the Filter class to guarantee the consistent
+ // ability to load this class from any thread
+ ClassLoader saveCtxCl = Thread.currentThread().getContextClassLoader();
+ try {
+ Thread.currentThread().setContextClassLoader(
+ Filter.class.getClassLoader());
+ CONF = HBaseConfiguration.create();
+ } finally {
+ Thread.currentThread().setContextClassLoader(saveCtxCl);
+ }
+ }
private static final int MAX_LOG_FILTERS = 5;
private Operator operator = Operator.MUST_PASS_ALL;
private List<Filter> filters = new ArrayList<Filter>();
@@ -321,7 +337,7 @@ public class FilterList implements Filter {
if (size > 0) {
filters = new ArrayList<Filter>(size);
for (int i = 0; i < size; i++) {
- Filter filter = HbaseObjectWritable.readFilter(in, conf);
+ Filter filter = HbaseObjectWritable.readFilter(in, CONF);
filters.add(filter);
}
}
@@ -331,7 +347,7 @@ public class FilterList implements Filter {
out.writeByte(operator.ordinal());
out.writeInt(filters.size());
for (Filter filter : filters) {
- HbaseObjectWritable.writeObject(out, filter, Writable.class, conf);
+ HbaseObjectWritable.writeObject(out, filter, Writable.class, CONF);
}
}