Skip to content

Commit c21e430

Browse files
committed
Merge remote-tracking branch 'origin/main' into spill-scoreboard
2 parents eaecd35 + e7708be commit c21e430

9 files changed

Lines changed: 100 additions & 8 deletions

File tree

CHANGES.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ Release 4.1.0 - unreleased
1010
PipesResult constructor gained the serverTimings component; the previous
1111
three-argument constructor remains (TIKA-4835).
1212

13+
* tika-server and tika-async-cli now start from a config that contains
14+
// or /* */ comments, as the configuration docs have always said they
15+
may. The main loader accepted them; the steps that re-read the user's
16+
file to merge in server/CLI overrides (ConfigMerger, ensurePluginRoots)
17+
used their own bare parser and refused the whole file; they now use the
18+
shared TikaObjectMapperFactory mapper (TIKA-4834).
19+
1320
* The Kafka pipes iterator no longer stops at the first empty poll. A newly
1421
subscribed consumer spends its first poll(s) joining the group and returns
1522
empty even when the topic has a backlog, so the iterator could enqueue zero

tika-parent/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -319,8 +319,8 @@
319319
<metadata.forbiddenapis.signaturesFile>${maven.multiModuleProjectDirectory}/tika-parent/forbidden-apis-metadata-string-key-bans.txt</metadata.forbiddenapis.signaturesFile>
320320
<!-- dependency versions -->
321321
<!-- change threetenbp exclusion version -->
322-
<google.cloud.version>2.71.0</google.cloud.version>
323-
<aws2.version>2.54.2</aws2.version>
322+
<google.cloud.version>2.72.0</google.cloud.version>
323+
<aws2.version>2.54.3</aws2.version>
324324
<!-- WARNING: when you upgrade asm make sure that you update the
325325
OpCode in the initializer in org.apache.tika.parser.asm.XHTMLClassVisitor
326326
See TIKA-2992.
@@ -413,7 +413,7 @@
413413
<mockito-junit-jupiter.version>5.23.0</mockito-junit-jupiter.version>
414414
<netcdf-java.version>4.5.5</netcdf-java.version>
415415
<netty.version>4.2.17.Final</netty.version>
416-
<oak.jackrabbit.version>2.4.0</oak.jackrabbit.version>
416+
<oak.jackrabbit.version>2.6.0</oak.jackrabbit.version>
417417
<openjson.version>1.0.13</openjson.version>
418418
<opennlp.version>2.5.11</opennlp.version>
419419
<ops4j.version>1.5.1</ops4j.version>

tika-pipes/tika-async-cli/src/main/java/org/apache/tika/async/cli/TikaAsyncCLI.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838

3939
import org.apache.tika.config.EmbeddedLimits;
4040
import org.apache.tika.config.loader.TikaJsonConfig;
41+
import org.apache.tika.config.loader.TikaObjectMapperFactory;
4142
import org.apache.tika.exception.TikaConfigException;
4243
import org.apache.tika.parser.ParseContext;
4344
import org.apache.tika.pipes.api.FetchEmitTuple;
@@ -444,7 +445,8 @@ static String resolveDefaultPluginsDir() {
444445
* @return the config path to use (original if plugin-roots exists, or a new merged config)
445446
*/
446447
static Path ensurePluginRoots(Path originalConfigPath, String pluginsDir) throws IOException {
447-
ObjectMapper mapper = new ObjectMapper();
448+
// The shared config mapper: same comment and strictness rules as the main loader.
449+
ObjectMapper mapper = TikaObjectMapperFactory.getMapper();
448450
JsonNode rootNode = mapper.readTree(originalConfigPath.toFile());
449451

450452
if (rootNode.has("plugin-roots")) {

tika-pipes/tika-async-cli/src/test/java/org/apache/tika/async/cli/AsyncCliParserTest.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,23 @@ public void testFileListDefaultsOutputDir(@TempDir Path tmp) throws Exception {
159159
@TempDir
160160
Path tempDir;
161161

162+
/** TIKA-4834: the config docs permit comments. */
163+
@Test
164+
public void testEnsurePluginRootsAcceptsComments() throws Exception {
165+
Path configPath = tempDir.resolve("config-comments.json");
166+
Files.writeString(configPath, """
167+
// leading comment
168+
{
169+
/* block */
170+
"pipes": { "numClients": 3 } // trailing
171+
}
172+
""");
173+
Path result = TikaAsyncCLI.ensurePluginRoots(configPath, null);
174+
JsonNode root = new ObjectMapper().readTree(result.toFile());
175+
assertTrue(root.has("plugin-roots"));
176+
assertEquals(3, root.get("pipes").get("numClients").asInt());
177+
}
178+
162179
@Test
163180
public void testEnsurePluginRootsAddsDefault() throws Exception {
164181
// Create a config without plugin-roots

tika-pipes/tika-pipes-core/src/main/java/org/apache/tika/pipes/core/config/ConfigMerger.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@
2727

2828
import com.fasterxml.jackson.databind.JsonNode;
2929
import com.fasterxml.jackson.databind.ObjectMapper;
30-
import com.fasterxml.jackson.databind.SerializationFeature;
3130
import com.fasterxml.jackson.databind.node.ArrayNode;
3231
import com.fasterxml.jackson.databind.node.ObjectNode;
3332
import org.slf4j.Logger;
3433
import org.slf4j.LoggerFactory;
3534

3635
import org.apache.tika.config.TimeoutLimits;
36+
import org.apache.tika.config.loader.TikaObjectMapperFactory;
3737
import org.apache.tika.pipes.api.ComponentIds;
3838

3939
/**
@@ -90,8 +90,8 @@ private ConfigMerger() {
9090
*/
9191
public static MergeResult mergeOrCreate(Path existingConfig, ConfigOverrides overrides)
9292
throws IOException {
93-
ObjectMapper mapper = new ObjectMapper();
94-
mapper.enable(SerializationFeature.INDENT_OUTPUT);
93+
// The shared config mapper: same comment and strictness rules as the main loader.
94+
ObjectMapper mapper = TikaObjectMapperFactory.getMapper();
9595

9696
ObjectNode root;
9797
if (existingConfig != null && Files.exists(existingConfig)) {

tika-pipes/tika-pipes-core/src/test/java/org/apache/tika/pipes/core/config/ConfigMergerTest.java

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,40 @@ public void testCreateNewConfig() throws IOException {
8282
Files.deleteIfExists(result.configPath());
8383
}
8484

85+
/** TIKA-4834: the config docs permit comments; the merge step must not reject them. */
86+
@Test
87+
public void testMergeWithCommentedConfig() throws IOException {
88+
String existingConfig = """
89+
// leading line comment
90+
{
91+
/* block comment */
92+
"fetchers": {
93+
"existing-fetcher": { // trailing comment
94+
"file-system-fetcher": {
95+
"basePath": "/existing/path"
96+
}
97+
}
98+
},
99+
"plugin-roots": "existing-plugins"
100+
}
101+
""";
102+
Path existingPath = tempDir.resolve("commented-config.json");
103+
Files.writeString(existingPath, existingConfig);
104+
105+
ConfigOverrides overrides = ConfigOverrides.builder()
106+
.addFetcher("new-fetcher", "file-system-fetcher", Map.of("basePath", "/new/path"))
107+
.build();
108+
ConfigMerger.MergeResult result = ConfigMerger.mergeOrCreate(existingPath, overrides);
109+
110+
// The merged file is plain JSON: readable by a strict mapper, content intact.
111+
JsonNode root = new ObjectMapper().readTree(result.configPath().toFile());
112+
assertEquals("/existing/path", root.get("fetchers").get("existing-fetcher")
113+
.get("file-system-fetcher").get("basePath").asText());
114+
assertTrue(root.get("fetchers").has("new-fetcher"));
115+
assertEquals("existing-plugins", root.get("plugin-roots").asText());
116+
Files.deleteIfExists(result.configPath());
117+
}
118+
85119
@Test
86120
public void testMergeWithExistingConfig() throws IOException {
87121
// Create existing config

tika-pipes/tika-pipes-plugins/tika-pipes-google-drive/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<name>Apache Tika Pipes Google Drive</name>
3030
<properties>
3131
<google-api-services-drive.version>v3-rev20260720-2.0.0</google-api-services-drive.version>
32-
<google-auth-library-oauth2-http.version>1.50.0</google-auth-library-oauth2-http.version>
32+
<google-auth-library-oauth2-http.version>1.51.0</google-auth-library-oauth2-http.version>
3333
<google-api-client.version>2.9.0</google-api-client.version>
3434
<google-http-client.version>2.2.0</google-http-client.version>
3535
</properties>

tika-server/tika-server-core/src/test/java/org/apache/tika/server/core/TikaServerIntegrationTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,18 @@ public void testBasic() throws Exception {
100100
testBaseline();
101101
}
102102

103+
/** TIKA-4834: the docs permit comments in the config; the server must start from one. */
104+
@Test
105+
public void testCommentedConfig() throws Exception {
106+
startProcess(new String[]{"-config", getConfig("tika-config-server-comments.json")});
107+
awaitServerStartup();
108+
Response response = WebClient
109+
.create(endPoint + RMETA_PATH)
110+
.accept("application/json")
111+
.put(ClassLoader.getSystemResourceAsStream(TEST_HELLO_WORLD));
112+
assertEquals(200, response.getStatus());
113+
}
114+
103115
@Test
104116
public void testBasicWithPipes() throws Exception {
105117
// Test that pipes-based parsing works for normal documents
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// TIKA-4834: comments everywhere the docs say they are allowed
2+
{
3+
/* block comment before a key */
4+
"server": {
5+
"port": 9999, // trailing comment
6+
"allowPipes": true,
7+
"endpoints": [
8+
"rmeta",
9+
// comment inside an array
10+
"tika"
11+
]
12+
},
13+
"pipes": {
14+
"numClients": 1,
15+
"forkedJvmArgs": [
16+
"-Xmx256m"
17+
]
18+
},
19+
"plugin-roots": "target/plugins"
20+
}

0 commit comments

Comments
 (0)