This is an automated email from the ASF dual-hosted git repository.
exceptionfactory pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git
The following commit(s) were added to refs/heads/main by this push:
new 66a88160cb8 NIFI-16189 Deprecated StreamUtils.read(InputStream,byte[]
destination, int) (#11533)
66a88160cb8 is described below
commit 66a88160cb825e2e818553816f6060ed460e45fc
Author: dan-s1 <[email protected]>
AuthorDate: Wed Aug 12 15:37:16 2026 -0400
NIFI-16189 Deprecated StreamUtils.read(InputStream,byte[] destination, int)
(#11533)
Signed-off-by: David Handermann <[email protected]>
---
.../src/main/java/org/apache/nifi/stream/io/StreamUtils.java | 2 ++
.../java/org/apache/nifi/processors/network/pcap/SplitPCAP.java | 7 +++----
.../queue/clustered/server/StandardLoadBalanceProtocol.java | 2 +-
3 files changed, 6 insertions(+), 5 deletions(-)
diff --git
a/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/StreamUtils.java
b/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/StreamUtils.java
index 89ab54d554a..6d04b624fa7 100644
---
a/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/StreamUtils.java
+++
b/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/StreamUtils.java
@@ -120,7 +120,9 @@ public class StreamUtils {
* @throws IllegalArgumentException if the given byte array is smaller
than <code>byteCount</code> elements.
* @throws EOFException if the InputStream does not have
<code>byteCount</code> bytes in the InputStream
* @throws IOException if unable to read from the InputStream
+ * @deprecated Use {@link InputStream#readNBytes(byte[], int, int)}
instead.
*/
+ @Deprecated(since = "2.12.0", forRemoval = true)
public static void read(final InputStream source, final byte[]
destination, final int byteCount) throws IOException {
if (destination.length < byteCount) {
throw new IllegalArgumentException();
diff --git
a/nifi-extension-bundles/nifi-network-bundle/nifi-network-processors/src/main/java/org/apache/nifi/processors/network/pcap/SplitPCAP.java
b/nifi-extension-bundles/nifi-network-bundle/nifi-network-processors/src/main/java/org/apache/nifi/processors/network/pcap/SplitPCAP.java
index 89500362ffe..feeb47a39d9 100644
---
a/nifi-extension-bundles/nifi-network-bundle/nifi-network-processors/src/main/java/org/apache/nifi/processors/network/pcap/SplitPCAP.java
+++
b/nifi-extension-bundles/nifi-network-bundle/nifi-network-processors/src/main/java/org/apache/nifi/processors/network/pcap/SplitPCAP.java
@@ -35,7 +35,6 @@ import org.apache.nifi.processor.Relationship;
import org.apache.nifi.processor.exception.ProcessException;
import org.apache.nifi.processor.io.InputStreamCallback;
import org.apache.nifi.processor.util.StandardValidators;
-import org.apache.nifi.stream.io.StreamUtils;
import java.io.BufferedInputStream;
import java.io.IOException;
@@ -196,7 +195,7 @@ public class SplitPCAP extends AbstractProcessor {
private Packet getNextPacket(final BufferedInputStream bufferedStream,
final PCAP templatePcap, final int totalPackets) throws IOException {
final byte[] packetHeader = new byte[Packet.PACKET_HEADER_LENGTH];
- StreamUtils.read(bufferedStream, packetHeader,
Packet.PACKET_HEADER_LENGTH);
+ bufferedStream.readNBytes(packetHeader, 0,
Packet.PACKET_HEADER_LENGTH);
final Packet currentPacket = new Packet(packetHeader,
templatePcap);
@@ -206,7 +205,7 @@ public class SplitPCAP extends AbstractProcessor {
final int expectedLength = (int) currentPacket.expectedLength();
final byte[] packetBody = new byte[expectedLength];
- StreamUtils.read(bufferedStream, packetBody, expectedLength);
+ bufferedStream.readNBytes(packetBody, 0, expectedLength);
currentPacket.setBody(packetBody);
if (currentPacket.isInvalid()) {
@@ -227,7 +226,7 @@ public class SplitPCAP extends AbstractProcessor {
}
final byte[] pcapHeader = new byte[PCAPHeader.PCAP_HEADER_LENGTH];
- StreamUtils.read(bufferedStream, pcapHeader,
PCAPHeader.PCAP_HEADER_LENGTH);
+ bufferedStream.readNBytes(pcapHeader, 0,
PCAPHeader.PCAP_HEADER_LENGTH);
int currentPcapTotalLength = PCAPHeader.PCAP_HEADER_LENGTH;
diff --git
a/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/queue/clustered/server/StandardLoadBalanceProtocol.java
b/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/queue/clustered/server/StandardLoadBalanceProtocol.java
index ad0592f485f..43a7a2977bc 100644
---
a/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/queue/clustered/server/StandardLoadBalanceProtocol.java
+++
b/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/queue/clustered/server/StandardLoadBalanceProtocol.java
@@ -452,7 +452,7 @@ public class StandardLoadBalanceProtocol implements
LoadBalanceProtocol {
private long readChecksum(final InputStream in) throws IOException {
final byte[] buffer = getDataBuffer();
- StreamUtils.read(in, buffer, 8);
+ in.readNBytes(buffer, 0, 8);
return ByteBuffer.wrap(buffer, 0, 8).getLong();
}