|
8 | 8 | package com.tangosol.util;
|
9 | 9 |
|
10 | 10 | import com.oracle.coherence.common.base.Logger;
|
| 11 | +import com.oracle.coherence.common.io.BufferManagers; |
11 | 12 |
|
12 | 13 | import com.tangosol.coherence.config.Config;
|
13 | 14 |
|
| 15 | +import com.tangosol.internal.io.BufferManagerWriteBufferPool; |
14 | 16 | import com.tangosol.internal.util.invoke.Lambdas;
|
15 | 17 | import com.tangosol.internal.util.invoke.RemotableSupport;
|
16 | 18 |
|
@@ -6625,20 +6627,21 @@ protected static char[] readLargeCharArray(Utf8Reader reader, int cLength)
|
6625 | 6627 | protected static byte[] readLargeByteArray(DataInput in, int cb)
|
6626 | 6628 | throws IOException
|
6627 | 6629 | {
|
6628 |
| - int cBatchMax = CHUNK_SIZE; |
6629 |
| - int cBatch = cb / cBatchMax + 1; |
6630 |
| - byte[] ab = new byte[cBatchMax]; |
6631 |
| - byte[] aMerged = null; |
6632 |
| - int cbRead = 0; |
6633 |
| - for (int i = 0; i < cBatch && cbRead < cb; i++) |
| 6630 | + int cbBatchMax = CHUNK_SIZE; |
| 6631 | + int cBatch = cb / cbBatchMax + 1; |
| 6632 | + |
| 6633 | + try (MultiBufferWriteBuffer buf = new MultiBufferWriteBuffer(new BufferManagerWriteBufferPool(BufferManagers.getHeapManager()), cbBatchMax)) |
6634 | 6634 | {
|
6635 |
| - in.readFully(ab); |
6636 |
| - aMerged = mergeByteArray(aMerged, ab); |
6637 |
| - cbRead += ab.length; |
6638 |
| - ab = new byte[Math.min(cb - cbRead, cBatchMax)]; |
| 6635 | + InputStreaming input = new WrapperDataInputStream(in); |
| 6636 | + int cbRead = 0; |
| 6637 | + for (int i = 0; i < cBatch && cbRead < cb; i++) |
| 6638 | + { |
| 6639 | + int cbBatch = Math.min(cb - cbRead, cbBatchMax); |
| 6640 | + buf.write(cbRead, input, cbBatch); |
| 6641 | + cbRead += cbBatch; |
| 6642 | + } |
| 6643 | + return buf.toByteArray(); |
6639 | 6644 | }
|
6640 |
| - |
6641 |
| - return aMerged; |
6642 | 6645 | }
|
6643 | 6646 |
|
6644 | 6647 | /**
|
|
0 commit comments