Skip to content

Commit f7034b1

Browse files
author
Steve Powell
committed
Removed dependency on org.apache.commons.io.* from run-time code.
1 parent 63421cc commit f7034b1

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

src/com/rabbitmq/client/impl/TruncatedInputStream.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,15 @@
1717

1818
package com.rabbitmq.client.impl;
1919

20+
import java.io.FilterInputStream;
2021
import java.io.IOException;
2122
import java.io.InputStream;
2223

23-
import org.apache.commons.io.input.ProxyInputStream;
24-
2524
/**
2625
* Utility stream: proxies another stream, making it appear to be no
2726
* longer than a preset limit.
2827
*/
29-
public class TruncatedInputStream extends ProxyInputStream {
28+
public class TruncatedInputStream extends FilterInputStream {
3029
private final long limit;
3130

3231
private long counter = 0L;
@@ -57,10 +56,6 @@ public TruncatedInputStream(InputStream in, long limit) {
5756
return -1;
5857
}
5958

60-
@Override public int read(byte[] b) throws IOException {
61-
return read(b, 0, b.length);
62-
}
63-
6459
@Override public int read(byte[] b, int off, int len) throws IOException {
6560

6661
if (limit > counter) {

src/com/rabbitmq/client/impl/ValueWriter.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@
1919

2020
import java.io.DataOutputStream;
2121
import java.io.IOException;
22+
import java.io.InputStream;
23+
import java.io.OutputStream;
2224
import java.math.BigDecimal;
2325
import java.math.BigInteger;
2426
import java.util.Date;
2527
import java.util.Map;
2628
import java.util.List;
2729

28-
import org.apache.commons.io.IOUtils;
29-
3030
import com.rabbitmq.client.LongString;
3131

3232
/**
@@ -61,7 +61,18 @@ public final void writeLongstr(LongString str)
6161
throws IOException
6262
{
6363
writeLong((int)str.length());
64-
IOUtils.copy(str.getStream(), out);
64+
copy(str.getStream(), out);
65+
}
66+
67+
private static final int COPY_BUFFER_SIZE = 4096;
68+
69+
private static void copy(InputStream input, OutputStream output) throws IOException {
70+
byte[] buffer = new byte[COPY_BUFFER_SIZE];
71+
int biteSize = input.read(buffer);
72+
while (-1 != biteSize) {
73+
output.write(buffer, 0, biteSize);
74+
biteSize = input.read(buffer);
75+
}
6576
}
6677

6778
/** Public API - encodes a long string from a String. */

0 commit comments

Comments
 (0)