Fix configure issue with decorated parsers
Project: http://git-wip-us.apache.org/repos/asf/tika/repo Commit: http://git-wip-us.apache.org/repos/asf/tika/commit/71726bc1 Tree: http://git-wip-us.apache.org/repos/asf/tika/tree/71726bc1 Diff: http://git-wip-us.apache.org/repos/asf/tika/diff/71726bc1 Branch: refs/heads/master Commit: 71726bc1faafcfd955a99c38e20784dd5de61f89 Parents: 853750d Author: Thamme Gowda <[email protected]> Authored: Fri Jun 10 21:18:50 2016 -0700 Committer: Thamme Gowda <[email protected]> Committed: Fri Jun 10 21:18:50 2016 -0700 ---------------------------------------------------------------------- .../src/main/java/org/apache/tika/config/TikaConfig.java | 6 +++--- .../org/apache/tika/parser/ParameterizedParserTest.java | 9 +++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tika/blob/71726bc1/tika-core/src/main/java/org/apache/tika/config/TikaConfig.java ---------------------------------------------------------------------- diff --git a/tika-core/src/main/java/org/apache/tika/config/TikaConfig.java b/tika-core/src/main/java/org/apache/tika/config/TikaConfig.java index 853cdf0..1163d84 100644 --- a/tika-core/src/main/java/org/apache/tika/config/TikaConfig.java +++ b/tika-core/src/main/java/org/apache/tika/config/TikaConfig.java @@ -563,9 +563,7 @@ public class TikaConfig { // TODO Support arguments, needed for Translators etc // See the thread "Configuring parsers and translators" for details } - - // Have any decoration performed, eg explicit mimetypes - loaded = decorate(loaded, element); + //if the instance is configurable, then call configure() if (loaded instanceof Configurable){ Map<String, Param<?>> params = getParams(element); @@ -576,6 +574,8 @@ public class TikaConfig { context.getParams().putAll(params); ((Configurable) loaded).configure(context); // initialize here } + // Have any decoration performed, eg explicit mimetypes + loaded = decorate(loaded, element); // All done with setup return loaded; } catch (ClassNotFoundException e) { http://git-wip-us.apache.org/repos/asf/tika/blob/71726bc1/tika-core/src/test/java/org/apache/tika/parser/ParameterizedParserTest.java ---------------------------------------------------------------------- diff --git a/tika-core/src/test/java/org/apache/tika/parser/ParameterizedParserTest.java b/tika-core/src/test/java/org/apache/tika/parser/ParameterizedParserTest.java index e0c3b53..c524e43 100644 --- a/tika-core/src/test/java/org/apache/tika/parser/ParameterizedParserTest.java +++ b/tika-core/src/test/java/org/apache/tika/parser/ParameterizedParserTest.java @@ -67,6 +67,15 @@ public class ParameterizedParserTest { } @Test + public void testConfigurableParserTypesDecorated() throws Exception { + Metadata md = getMetadata("TIKA-1986-parameterized-decorated.xml"); + for (Map.Entry<String, String> entry : expcted.entrySet()) { + assertEquals("mismatch for " + entry.getKey(), entry.getValue(), md.get(entry.getKey())); + } + } + + + @Test public void testSomeParams() throws Exception { //test that a parameterized parser can read a config file //with only some changes to the initial values
