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 a569a6d4e TIKA-4440: replace deprecated
a569a6d4e is described below

commit a569a6d4ea201f9ea22d25217d0543ca431cb174
Author: Tilman Hausherr <til...@apache.org>
AuthorDate: Mon Jun 30 19:56:05 2025 +0200

    TIKA-4440: replace deprecated
---
 .../apache/tika/serialization/ParseContextDeserializer.java   |  5 +----
 .../org/apache/tika/serialization/TikaJsonDeserializer.java   | 11 +++--------
 .../apache/tika/serialization/pipes/JsonFetchEmitTuple.java   |  9 ++-------
 3 files changed, 6 insertions(+), 19 deletions(-)

diff --git 
a/tika-serialization/src/main/java/org/apache/tika/serialization/ParseContextDeserializer.java
 
b/tika-serialization/src/main/java/org/apache/tika/serialization/ParseContextDeserializer.java
index b6b2f918a..f37e2c07e 100644
--- 
a/tika-serialization/src/main/java/org/apache/tika/serialization/ParseContextDeserializer.java
+++ 
b/tika-serialization/src/main/java/org/apache/tika/serialization/ParseContextDeserializer.java
@@ -19,7 +19,6 @@ package org.apache.tika.serialization;
 import static 
org.apache.tika.serialization.ParseContextSerializer.PARSE_CONTEXT;
 
 import java.io.IOException;
-import java.util.Iterator;
 import java.util.Map;
 
 import com.fasterxml.jackson.core.JacksonException;
@@ -48,9 +47,7 @@ public class ParseContextDeserializer extends 
JsonDeserializer<ParseContext> {
             contextNode = jsonNode;
         }
         ParseContext parseContext = new ParseContext();
-        Iterator<Map.Entry<String, JsonNode>> it = contextNode.fields();
-        while (it.hasNext()) {
-            Map.Entry<String, JsonNode> e = it.next();
+        for (Map.Entry<String, JsonNode> e : contextNode.properties()) {
             String superClassName = e.getKey();
             JsonNode obj = e.getValue();
             String className = 
readVal(TikaJsonSerializer.INSTANTIATED_CLASS_KEY, obj, null, true);
diff --git 
a/tika-serialization/src/main/java/org/apache/tika/serialization/TikaJsonDeserializer.java
 
b/tika-serialization/src/main/java/org/apache/tika/serialization/TikaJsonDeserializer.java
index b346e8775..1b180afdc 100644
--- 
a/tika-serialization/src/main/java/org/apache/tika/serialization/TikaJsonDeserializer.java
+++ 
b/tika-serialization/src/main/java/org/apache/tika/serialization/TikaJsonDeserializer.java
@@ -23,7 +23,6 @@ import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
 import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Optional;
@@ -63,9 +62,7 @@ public class TikaJsonDeserializer {
         if (!root.isObject()) {
             throw new IllegalArgumentException("must be object");
         }
-        Iterator<Map.Entry<String, JsonNode>> fields = root.fields();
-        while (fields.hasNext()) {
-            Map.Entry<String, JsonNode> e = fields.next();
+        for (Map.Entry<String, JsonNode> e : root.properties()) {
             String name = e.getKey();
             JsonNode child = e.getValue();
             if (TikaJsonSerializer.INSTANTIATED_CLASS_KEY.equals(name)) {
@@ -99,7 +96,7 @@ public class TikaJsonDeserializer {
 
     private static void setValue(String name, JsonNode node, Object obj, 
Map<String, List<Method>> setters) throws ReflectiveOperationException {
         List<Method> mySetters = setters.get(name);
-        if (mySetters == null || mySetters.size() == 0) {
+        if (mySetters == null || mySetters.isEmpty()) {
             throw new IllegalArgumentException("can't find any setter for " + 
name);
         }
         if (node.isNull()) {
@@ -214,9 +211,7 @@ public class TikaJsonDeserializer {
         //TODO this should try to match the map setters with the data types
         //for now, we're just doing <String,String>
         Map<String, String> val = new HashMap<>();
-        Iterator<Map.Entry<String, JsonNode>> it = node.fields();
-        while (it.hasNext()) {
-            Map.Entry<String, JsonNode> e = it.next();
+        for (Map.Entry<String, JsonNode> e : node.properties()) {
             val.put(e.getKey(), e
                     .getValue()
                     .textValue());
diff --git 
a/tika-serialization/src/main/java/org/apache/tika/serialization/pipes/JsonFetchEmitTuple.java
 
b/tika-serialization/src/main/java/org/apache/tika/serialization/pipes/JsonFetchEmitTuple.java
index 7f153a44a..0987fdcf8 100644
--- 
a/tika-serialization/src/main/java/org/apache/tika/serialization/pipes/JsonFetchEmitTuple.java
+++ 
b/tika-serialization/src/main/java/org/apache/tika/serialization/pipes/JsonFetchEmitTuple.java
@@ -22,7 +22,6 @@ import java.io.IOException;
 import java.io.Reader;
 import java.io.StringWriter;
 import java.io.Writer;
-import java.util.Iterator;
 import java.util.Locale;
 import java.util.Map;
 
@@ -97,15 +96,11 @@ public class JsonFetchEmitTuple {
             return new Metadata();
         }
         Metadata metadata = new Metadata();
-        Iterator<Map.Entry<String, JsonNode>> it = metadataNode.fields();
-        while (it.hasNext()) {
-            Map.Entry<String, JsonNode> e = it.next();
+        for (Map.Entry<String, JsonNode> e : metadataNode.properties()) {
             JsonNode vals = e.getValue();
             String k = e.getKey();
             if (vals.isArray()) {
-                Iterator<JsonNode> arrIt = vals.iterator();
-                while (arrIt.hasNext()) {
-                    JsonNode arrVal = arrIt.next();
+                for (JsonNode arrVal : vals) {
                     metadata.add(k, arrVal.textValue());
                 }
             } else {

Reply via email to