This is an automated email from the ASF dual-hosted git repository.

tilman pushed a commit to branch branch_3x
in repository https://gitbox.apache.org/repos/asf/tika.git


The following commit(s) were added to refs/heads/branch_3x by this push:
     new 3dc10a4c5 TIKA-4485: fix relative files + test
3dc10a4c5 is described below

commit 3dc10a4c5edff1550821c96c683489e51fbab251
Author: Tilman Hausherr <[email protected]>
AuthorDate: Tue Sep 16 08:56:31 2025 +0200

    TIKA-4485: fix relative files + test
---
 .../java/org/apache/tika/config/TikaConfig.java     |  2 +-
 .../java/org/apache/tika/config/TikaConfigTest.java | 21 +++++++++++++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)

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 667f178d5..abe340a1f 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
@@ -364,7 +364,7 @@ public class TikaConfig {
         InputStream stream = null;
         try {
             stream = new URI(config).toURL().openStream();
-        } catch (IOException | URISyntaxException ignore) {
+        } catch (IOException | URISyntaxException | IllegalArgumentException 
ignore) {
         }
         if (stream == null) {
             stream = serviceLoader.getResourceAsStream(config);
diff --git a/tika-core/src/test/java/org/apache/tika/config/TikaConfigTest.java 
b/tika-core/src/test/java/org/apache/tika/config/TikaConfigTest.java
index b89491414..97ff3f376 100644
--- a/tika-core/src/test/java/org/apache/tika/config/TikaConfigTest.java
+++ b/tika-core/src/test/java/org/apache/tika/config/TikaConfigTest.java
@@ -176,6 +176,27 @@ public class TikaConfigTest extends AbstractTikaConfigTest 
{
         assertNotNull(resources.get("custom-mimetypes.xml"));
     }
 
+    /**
+     * TIKA-4485: try a relative path with an empty constructor.
+     *
+     * @throws Exception 
+     */
+    @Test
+    void testEmptyConstructor() throws Exception {
+        // file that exists
+        System.setProperty("tika.config", 
"src/test/resources/org/apache/tika/config/TIKA-1445-default-except.xml");
+        TikaConfig tikaConfig = new TikaConfig();
+        // code from the TIKA-1445 test
+        CompositeParser cp = (CompositeParser) tikaConfig.getParser();
+        List<Parser> parsers = cp.getAllComponentParsers();
+        assertEquals(3, parsers.size());
+
+        // file that doesn't exist
+        System.setProperty("tika.config", "doesntexist.xml");
+        TikaException ex = assertThrows(TikaException.class, () -> new 
TikaConfig());
+        assertTrue(ex.getMessage().contains("Specified Tika configuration not 
found: doesntexist.xml"));        
+    }
+
     /**
      * TIKA-1445 It should be possible to exclude DefaultParser from
      * certain types, so another parser explicitly listed will take them

Reply via email to