This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 68586531f030 CAMEL-23436: camel-netty - Add type convert from
InputStream to ByteBuf (#23005)
68586531f030 is described below
commit 68586531f0303a0b00003f01a4655aea112deee3
Author: Claus Ibsen <[email protected]>
AuthorDate: Wed May 6 14:25:24 2026 +0200
CAMEL-23436: camel-netty - Add type convert from InputStream to ByteBuf
(#23005)
---
.../org/apache/camel/component/netty/NettyConverterLoader.java | 8 ++++++++
.../java/org/apache/camel/component/netty/NettyConverter.java | 7 +++++++
2 files changed, 15 insertions(+)
diff --git
a/components/camel-netty/src/generated/java/org/apache/camel/component/netty/NettyConverterLoader.java
b/components/camel-netty/src/generated/java/org/apache/camel/component/netty/NettyConverterLoader.java
index aa8f74b1a9d3..4dc3e712359f 100644
---
a/components/camel-netty/src/generated/java/org/apache/camel/component/netty/NettyConverterLoader.java
+++
b/components/camel-netty/src/generated/java/org/apache/camel/component/netty/NettyConverterLoader.java
@@ -60,6 +60,14 @@ public final class NettyConverterLoader implements
TypeConverterLoader, CamelCon
}
return answer;
});
+ addTypeConverter(registry, io.netty.buffer.ByteBuf.class,
java.io.InputStream.class, false,
+ (type, exchange, value) -> {
+ Object answer =
org.apache.camel.component.netty.NettyConverter.toByteBuffer((java.io.InputStream)
value, exchange);
+ if (false && answer == null) {
+ answer = Void.class;
+ }
+ return answer;
+ });
addTypeConverter(registry, io.netty.buffer.ByteBuf.class,
java.lang.String.class, false,
(type, exchange, value) -> {
Object answer =
org.apache.camel.component.netty.NettyConverter.toByteBuffer((java.lang.String)
value, exchange);
diff --git
a/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyConverter.java
b/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyConverter.java
index 720fc7895fae..3837a43e3fed 100644
---
a/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyConverter.java
+++
b/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyConverter.java
@@ -121,6 +121,13 @@ public final class NettyConverter {
return toByteBuffer(bytes);
}
+ @Converter
+ public static ByteBuf toByteBuffer(InputStream is, Exchange exchange) {
+ // convert to byte array first
+ byte[] arr =
exchange.getContext().getTypeConverter().convertTo(byte[].class, exchange, is);
+ return toByteBuffer(arr);
+ }
+
@Converter
public static Document toDocument(ByteBuf buffer, Exchange exchange) {
InputStream is = toInputStream(buffer, exchange);