Util: Deprecate BigPipedInputStream

This commit is contained in:
zzz
2017-12-07 19:53:06 +00:00
parent 1f569b7359
commit f34b4678ba
4 changed files with 9 additions and 20 deletions

View File

@ -3,6 +3,8 @@ package net.i2p.util;
import java.io.PipedInputStream;
/**
* We are now Java 6 minimum. Just use PipedInputStream.
*
* Java 1.5 PipedInputStream buffers are only 1024 bytes; our I2CP messages are typically 1730 bytes,
* thus causing thread blockage before the whole message is transferred.
* We can specify buffer size in 1.6 but not in 1.5.
@ -12,32 +14,19 @@ import java.io.PipedInputStream;
*
* Moved from InternalServerSocket.
* @since 0.8.9
* @deprecated scheduled for removal in 0.9.34
*/
@Deprecated
public class BigPipedInputStream extends PipedInputStream {
private static final boolean oneDotSix = SystemVersion.isJava6();
private static final int PIPE_SIZE = 64*1024;
private BigPipedInputStream(int size) {
super();
buffer = new byte[size];
}
/** default size 64K */
public static PipedInputStream getInstance() {
return getInstance(PIPE_SIZE);
}
public static PipedInputStream getInstance(int size) {
if (oneDotSix) {
try {
return new PipedInputStream(size);
} catch (Throwable t) {
// NoSuchMethodException or NoSuchMethodError if we somehow got the
// version detection wrong or the JVM doesn't support it
}
}
return new BigPipedInputStream(size);
}
}

View File

@ -793,7 +793,7 @@ public class EepGet {
if (_isGzippedResponse) {
if (_log.shouldInfo())
_log.info("Gzipped response, starting decompressor");
PipedInputStream pi = BigPipedInputStream.getInstance();
PipedInputStream pi = new PipedInputStream(64*1024);
PipedOutputStream po = new PipedOutputStream(pi);
pusher = new I2PAppThread(new Gunzipper(pi, _out), "EepGet Decompressor");
_out = po;

View File

@ -93,8 +93,8 @@ public class InternalServerSocket extends ServerSocket {
InternalServerSocket iss = _sockets.get(Integer.valueOf(port));
if (iss == null)
throw new IOException("No server for port: " + port);
PipedInputStream cis = BigPipedInputStream.getInstance();
PipedInputStream sis = BigPipedInputStream.getInstance();
PipedInputStream cis = new PipedInputStream(64*1024);
PipedInputStream sis = new PipedInputStream(64*1024);
PipedOutputStream cos = new PipedOutputStream(sis);
PipedOutputStream sos = new PipedOutputStream(cis);
clientSock.setInputStream(cis);

View File

@ -576,7 +576,7 @@ public class SSLEepGet extends EepGet {
Thread pusher = null;
_decompressException = null;
if (_isGzippedResponse) {
PipedInputStream pi = BigPipedInputStream.getInstance();
PipedInputStream pi = new PipedInputStream(64*1024);
PipedOutputStream po = new PipedOutputStream(pi);
pusher = new I2PAppThread(new Gunzipper(pi, _out), "EepGet Decompressor");
_out = po;