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

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

commit 556138fb7713d3db0731c0eeeafe9690b5110ade
Author: Tilman Hausherr <til...@apache.org>
AuthorDate: Sat Aug 10 15:28:09 2024 +0200

    TIKA-4290: replace deprecated
---
 .../src/main/java/org/apache/tika/parser/html/HtmlHandler.java    | 8 ++++----
 .../parser/microsoft/ooxml/xwpf/ml2006/BinaryDataHandler.java     | 4 ++--
 .../src/main/java/org/apache/tika/parser/dbf/DBFCell.java         | 3 +--
 .../main/java/org/apache/tika/parser/xml/FictionBookParser.java   | 2 +-
 4 files changed, 8 insertions(+), 9 deletions(-)

diff --git 
a/tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-html-module/src/main/java/org/apache/tika/parser/html/HtmlHandler.java
 
b/tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-html-module/src/main/java/org/apache/tika/parser/html/HtmlHandler.java
index 3050422c4..17912125d 100644
--- 
a/tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-html-module/src/main/java/org/apache/tika/parser/html/HtmlHandler.java
+++ 
b/tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-html-module/src/main/java/org/apache/tika/parser/html/HtmlHandler.java
@@ -354,7 +354,7 @@ class HtmlHandler extends TextContentHandler {
         EmbeddedDocumentExtractor embeddedDocumentExtractor =
                 EmbeddedDocumentUtil.getEmbeddedDocumentExtractor(context);
         if (embeddedDocumentExtractor.shouldParseEmbedded(m)) {
-            try (InputStream stream = new 
UnsynchronizedByteArrayInputStream(string.getBytes(StandardCharsets.UTF_8))) {
+            try (InputStream stream = 
UnsynchronizedByteArrayInputStream.builder().setByteArray(string.getBytes(StandardCharsets.UTF_8)).get())
 {
                 embeddedDocumentExtractor.parseEmbedded(stream, xhtml, m, 
true);
             } catch (IOException e) {
                 EmbeddedDocumentUtil.recordEmbeddedStreamException(e, 
metadata);
@@ -363,7 +363,7 @@ class HtmlHandler extends TextContentHandler {
     }
 
     private void handleDataURIScheme(String string) throws SAXException {
-        DataURIScheme dataURIScheme = null;
+        DataURIScheme dataURIScheme;
         try {
             dataURIScheme = dataURISchemeUtil.parse(string);
         } catch (DataURISchemeParseException e) {
@@ -423,8 +423,8 @@ class HtmlHandler extends TextContentHandler {
             }
         }
 
-        try (InputStream stream = new UnsynchronizedByteArrayInputStream(
-                script.toString().getBytes(StandardCharsets.UTF_8))) {
+        try (InputStream stream = 
UnsynchronizedByteArrayInputStream.builder().setByteArray(
+                script.toString().getBytes(StandardCharsets.UTF_8)).get()) {
             embeddedDocumentExtractor.parseEmbedded(stream, xhtml, m, true);
         } catch (IOException e) {
             //shouldn't ever happen
diff --git 
a/tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-microsoft-module/src/main/java/org/apache/tika/parser/microsoft/ooxml/xwpf/ml2006/BinaryDataHandler.java
 
b/tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-microsoft-module/src/main/java/org/apache/tika/parser/microsoft/ooxml/xwpf/ml2006/BinaryDataHandler.java
index ad75c096a..734cdefdf 100644
--- 
a/tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-microsoft-module/src/main/java/org/apache/tika/parser/microsoft/ooxml/xwpf/ml2006/BinaryDataHandler.java
+++ 
b/tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-microsoft-module/src/main/java/org/apache/tika/parser/microsoft/ooxml/xwpf/ml2006/BinaryDataHandler.java
@@ -113,8 +113,8 @@ class BinaryDataHandler extends AbstractPartHandler {
         return buffer.length() > 0;
     }
 
-    private InputStream getInputStream() {
+    private InputStream getInputStream() throws IOException {
         byte[] bytes = base64.decode(buffer.toString());
-        return new UnsynchronizedByteArrayInputStream(bytes);
+        return 
UnsynchronizedByteArrayInputStream.builder().setByteArray(bytes).get();
     }
 }
diff --git 
a/tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-miscoffice-module/src/main/java/org/apache/tika/parser/dbf/DBFCell.java
 
b/tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-miscoffice-module/src/main/java/org/apache/tika/parser/dbf/DBFCell.java
index 8c762c764..d0b66976c 100644
--- 
a/tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-miscoffice-module/src/main/java/org/apache/tika/parser/dbf/DBFCell.java
+++ 
b/tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-miscoffice-module/src/main/java/org/apache/tika/parser/dbf/DBFCell.java
@@ -130,8 +130,7 @@ class DBFCell {
                 GregorianCalendar.getInstance(TimeZone.getTimeZone("UTC"), 
Locale.ROOT);
 //        baseCalendar.set(1899, 11, 31, 0, 0, 0);
         baseCalendar.set(-4712, 0, 1, 0, 0, 0);
-        try (InputStream is = new 
UnsynchronizedByteArrayInputStream(getBytes())) {
-
+        try (InputStream is = 
UnsynchronizedByteArrayInputStream.builder().setByteArray(getBytes()).get()) {
             int date = EndianUtils.readIntLE(is);
             int time = EndianUtils.readIntLE(is);
             baseCalendar.add(Calendar.DATE, date);
diff --git 
a/tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-xml-module/src/main/java/org/apache/tika/parser/xml/FictionBookParser.java
 
b/tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-xml-module/src/main/java/org/apache/tika/parser/xml/FictionBookParser.java
index 52e9e069d..4e7f0dad7 100644
--- 
a/tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-xml-module/src/main/java/org/apache/tika/parser/xml/FictionBookParser.java
+++ 
b/tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-xml-module/src/main/java/org/apache/tika/parser/xml/FictionBookParser.java
@@ -87,7 +87,7 @@ public class FictionBookParser extends XMLParser {
         public void endElement(String uri, String localName, String qName) 
throws SAXException {
             if (binaryMode) {
                 try (InputStream stream =
-                             new 
UnsynchronizedByteArrayInputStream(Base64.decodeBase64(binaryData.toString()))) 
{
+                             
UnsynchronizedByteArrayInputStream.builder().setByteArray(Base64.decodeBase64(binaryData.toString())).get())
 {
                     partExtractor.parseEmbedded(
                             stream, handler, metadata, true);
                 } catch (IOException e) {

Reply via email to