From 5556edc28a049b61fc475dd2750c64e7ac5f5815 Mon Sep 17 00:00:00 2001 From: Nick Molcanov <32801560+nck-mlcnv@users.noreply.github.com> Date: Tue, 29 Oct 2024 15:38:35 +0100 Subject: [PATCH 1/2] Fix StreamEntityProducer not able to repeat the production of the content --- .../cc/utils/http/StreamEntityProducer.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/aksw/iguana/cc/utils/http/StreamEntityProducer.java b/src/main/java/org/aksw/iguana/cc/utils/http/StreamEntityProducer.java index 5996d2b9e..08e41f42c 100644 --- a/src/main/java/org/aksw/iguana/cc/utils/http/StreamEntityProducer.java +++ b/src/main/java/org/aksw/iguana/cc/utils/http/StreamEntityProducer.java @@ -39,13 +39,11 @@ public class StreamEntityProducer implements AsyncEntityProducer { * @param streamSupplier the input stream supplier, should be repeatable * @param chunked whether the entity data should be sent in chunks */ - public StreamEntityProducer(Supplier streamSupplier, boolean chunked, String contentType) throws IOException { + public StreamEntityProducer(Supplier streamSupplier, boolean chunked, String contentType) { this.streamSupplier = streamSupplier; this.chunked = chunked; this.contentType = contentType; - if (!chunked) { - content = (streamSupplier.get() instanceof ByteArrayListInputStream) ? (ByteArrayListInputStream) streamSupplier.get() : null; - } + if (!chunked) loadContent(); } @Override @@ -132,7 +130,8 @@ public int available() { @Override public void produce(DataStreamChannel channel) throws IOException { // handling of non-chunked request - if (content != null) { + if (!chunked) { + if (content == null) loadContent(); // might be necessary if the producer is reused ByteBuffer buffer = content.getCurrentBuffer(); while (channel.write(buffer) > 0) { if (!buffer.hasRemaining()) { @@ -148,7 +147,7 @@ public void produce(DataStreamChannel channel) throws IOException { } // handling of chunked request - if (chunked && currentStream == null) { + if (currentStream == null) { currentStream = streamSupplier.get(); } @@ -162,4 +161,8 @@ public void produce(DataStreamChannel channel) throws IOException { channel.endStream(); } } + + private void loadContent() { + content = (ByteArrayListInputStream) streamSupplier.get(); + } } \ No newline at end of file From 2a6d7bc125bc8d4166b0a8064fd5c41c831ae746 Mon Sep 17 00:00:00 2001 From: Nick Molcanov <32801560+nck-mlcnv@users.noreply.github.com> Date: Tue, 29 Oct 2024 15:42:28 +0100 Subject: [PATCH 2/2] Update version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b4b9049ec..83132d480 100644 --- a/pom.xml +++ b/pom.xml @@ -38,7 +38,7 @@ ${major.version}.${minor.version} 4 1 - 0 + 1 17 4.2.0