This is an automated email from the ASF dual-hosted git repository. orpiske pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
commit 6f5bc3c3db36568604855bbc9a2052329fe5e2bc Author: Otavio Rodolfo Piske <[email protected]> AuthorDate: Fri Feb 6 13:38:32 2026 +0000 (chores): modernize instanceof checks in camel-docling --- .../java/org/apache/camel/component/docling/DoclingProducer.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/components/camel-ai/camel-docling/src/main/java/org/apache/camel/component/docling/DoclingProducer.java b/components/camel-ai/camel-docling/src/main/java/org/apache/camel/component/docling/DoclingProducer.java index f32943cef3d1..90985f103ab6 100644 --- a/components/camel-ai/camel-docling/src/main/java/org/apache/camel/component/docling/DoclingProducer.java +++ b/components/camel-ai/camel-docling/src/main/java/org/apache/camel/component/docling/DoclingProducer.java @@ -969,8 +969,7 @@ public class DoclingProducer extends DefaultProducer { // unwrap camel-file/camel-ftp and other file based components body = wf.getBody(); } - if (body instanceof String) { - String content = (String) body; + if (body instanceof String content) { // Check if it's a URL (http:// or https://) or a file path if (content.startsWith("http://") || content.startsWith("https://")) { // Return URL as-is, no validation needed @@ -986,16 +985,14 @@ public class DoclingProducer extends DefaultProducer { validateFileSize(tempFile.toString()); return tempFile.toString(); } - } else if (body instanceof byte[]) { - byte[] content = (byte[]) body; + } else if (body instanceof byte[] content) { if (content.length > configuration.getMaxFileSize()) { throw new IllegalArgumentException("File size exceeds maximum allowed size: " + configuration.getMaxFileSize()); } Path tempFile = Files.createTempFile("docling-", ".tmp"); Files.write(tempFile, content); return tempFile.toString(); - } else if (body instanceof File) { - File file = (File) body; + } else if (body instanceof File file) { validateFileSize(file.getAbsolutePath()); return file.getAbsolutePath(); }
