forked from I2P_Developers/i2p.i2p
Util: Deprecate BigPipedInputStream
This commit is contained in:
@ -3,6 +3,8 @@ package net.i2p.util;
|
|||||||
import java.io.PipedInputStream;
|
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,
|
* 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.
|
* thus causing thread blockage before the whole message is transferred.
|
||||||
* We can specify buffer size in 1.6 but not in 1.5.
|
* We can specify buffer size in 1.6 but not in 1.5.
|
||||||
@ -12,32 +14,19 @@ import java.io.PipedInputStream;
|
|||||||
*
|
*
|
||||||
* Moved from InternalServerSocket.
|
* Moved from InternalServerSocket.
|
||||||
* @since 0.8.9
|
* @since 0.8.9
|
||||||
|
* @deprecated scheduled for removal in 0.9.34
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public class BigPipedInputStream extends PipedInputStream {
|
public class BigPipedInputStream extends PipedInputStream {
|
||||||
|
|
||||||
private static final boolean oneDotSix = SystemVersion.isJava6();
|
|
||||||
|
|
||||||
private static final int PIPE_SIZE = 64*1024;
|
private static final int PIPE_SIZE = 64*1024;
|
||||||
|
|
||||||
private BigPipedInputStream(int size) {
|
|
||||||
super();
|
|
||||||
buffer = new byte[size];
|
|
||||||
}
|
|
||||||
|
|
||||||
/** default size 64K */
|
/** default size 64K */
|
||||||
public static PipedInputStream getInstance() {
|
public static PipedInputStream getInstance() {
|
||||||
return getInstance(PIPE_SIZE);
|
return getInstance(PIPE_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PipedInputStream getInstance(int size) {
|
public static PipedInputStream getInstance(int size) {
|
||||||
if (oneDotSix) {
|
|
||||||
try {
|
|
||||||
return new PipedInputStream(size);
|
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -793,7 +793,7 @@ public class EepGet {
|
|||||||
if (_isGzippedResponse) {
|
if (_isGzippedResponse) {
|
||||||
if (_log.shouldInfo())
|
if (_log.shouldInfo())
|
||||||
_log.info("Gzipped response, starting decompressor");
|
_log.info("Gzipped response, starting decompressor");
|
||||||
PipedInputStream pi = BigPipedInputStream.getInstance();
|
PipedInputStream pi = new PipedInputStream(64*1024);
|
||||||
PipedOutputStream po = new PipedOutputStream(pi);
|
PipedOutputStream po = new PipedOutputStream(pi);
|
||||||
pusher = new I2PAppThread(new Gunzipper(pi, _out), "EepGet Decompressor");
|
pusher = new I2PAppThread(new Gunzipper(pi, _out), "EepGet Decompressor");
|
||||||
_out = po;
|
_out = po;
|
||||||
|
@ -93,8 +93,8 @@ public class InternalServerSocket extends ServerSocket {
|
|||||||
InternalServerSocket iss = _sockets.get(Integer.valueOf(port));
|
InternalServerSocket iss = _sockets.get(Integer.valueOf(port));
|
||||||
if (iss == null)
|
if (iss == null)
|
||||||
throw new IOException("No server for port: " + port);
|
throw new IOException("No server for port: " + port);
|
||||||
PipedInputStream cis = BigPipedInputStream.getInstance();
|
PipedInputStream cis = new PipedInputStream(64*1024);
|
||||||
PipedInputStream sis = BigPipedInputStream.getInstance();
|
PipedInputStream sis = new PipedInputStream(64*1024);
|
||||||
PipedOutputStream cos = new PipedOutputStream(sis);
|
PipedOutputStream cos = new PipedOutputStream(sis);
|
||||||
PipedOutputStream sos = new PipedOutputStream(cis);
|
PipedOutputStream sos = new PipedOutputStream(cis);
|
||||||
clientSock.setInputStream(cis);
|
clientSock.setInputStream(cis);
|
||||||
|
@ -576,7 +576,7 @@ public class SSLEepGet extends EepGet {
|
|||||||
Thread pusher = null;
|
Thread pusher = null;
|
||||||
_decompressException = null;
|
_decompressException = null;
|
||||||
if (_isGzippedResponse) {
|
if (_isGzippedResponse) {
|
||||||
PipedInputStream pi = BigPipedInputStream.getInstance();
|
PipedInputStream pi = new PipedInputStream(64*1024);
|
||||||
PipedOutputStream po = new PipedOutputStream(pi);
|
PipedOutputStream po = new PipedOutputStream(pi);
|
||||||
pusher = new I2PAppThread(new Gunzipper(pi, _out), "EepGet Decompressor");
|
pusher = new I2PAppThread(new Gunzipper(pi, _out), "EepGet Decompressor");
|
||||||
_out = po;
|
_out = po;
|
||||||
|
Reference in New Issue
Block a user