You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by al...@apache.org on 2015/04/17 09:55:14 UTC
svn commit: r1674230 -
/jackrabbit/oak/branches/1.0/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexEditorContext.java
Author: alexparvulescu
Date: Fri Apr 17 07:55:14 2015
New Revision: 1674230
URL: http://svn.apache.org/r1674230
Log:
OAK-2782 Tika not able to load class in case of custom config
- applied patch provided by Chetan
Modified:
jackrabbit/oak/branches/1.0/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexEditorContext.java
Modified: jackrabbit/oak/branches/1.0/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexEditorContext.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.0/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexEditorContext.java?rev=1674230&r1=1674229&r2=1674230&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.0/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexEditorContext.java (original)
+++ jackrabbit/oak/branches/1.0/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexEditorContext.java Fri Apr 17 07:55:14 2015
@@ -192,20 +192,26 @@ public class LuceneIndexEditorContext {
}
private static Parser initializeTikaParser(IndexDefinition definition) {
- if (definition.hasCustomTikaConfig()){
- InputStream is = definition.getTikaConfig();
- try {
- TikaConfig config = new TikaConfig(is);
- return new AutoDetectParser(config);
- } catch (IOException e){
- throw new RuntimeException("Error loading TikaConfig for "+ definition, e);
- } catch (SAXException e) {
- throw new RuntimeException("Error loading TikaConfig for "+ definition, e);
- } catch (TikaException e) {
- throw new RuntimeException("Error loading TikaConfig for "+ definition, e);
- } finally {
- IOUtils.closeQuietly(is);
+ ClassLoader existing = Thread.currentThread().getContextClassLoader();
+ try {
+ if (definition.hasCustomTikaConfig()) {
+ Thread.currentThread().setContextClassLoader(LuceneIndexEditorContext.class.getClassLoader());
+ InputStream is = definition.getTikaConfig();
+ try {
+ TikaConfig config = new TikaConfig(is);
+ return new AutoDetectParser(config);
+ } catch (IOException e) {
+ throw new RuntimeException("Error loading TikaConfig for " + definition, e);
+ } catch (SAXException e) {
+ throw new RuntimeException("Error loading TikaConfig for " + definition, e);
+ } catch (TikaException e) {
+ throw new RuntimeException("Error loading TikaConfig for " + definition, e);
+ } finally {
+ IOUtils.closeQuietly(is);
+ }
}
+ }finally {
+ Thread.currentThread().setContextClassLoader(existing);
}
return defaultParser;
}