forked from I2P_Developers/i2p.i2p
Findbugs all over
- volatile -> atomic - unused code and fields - closing streams - hashCode / equals - known non-null - Number.valueOf - new String Still avoiding SAM, BOB, SusiMail
This commit is contained in:
@@ -273,11 +273,10 @@ class HTTPResponseOutputStream extends FilterOutputStream {
|
||||
}
|
||||
|
||||
public void run() {
|
||||
ReusableGZIPInputStream _in = null;
|
||||
ReusableGZIPInputStream _in = ReusableGZIPInputStream.acquire();
|
||||
long written = 0;
|
||||
ByteArray ba = null;
|
||||
try {
|
||||
_in = ReusableGZIPInputStream.acquire();
|
||||
// blocking
|
||||
_in.initialize(_inRaw);
|
||||
ba = _cache.acquire();
|
||||
@@ -294,7 +293,7 @@ class HTTPResponseOutputStream extends FilterOutputStream {
|
||||
_log.info("Decompressed: " + written + ", " + _in.getTotalRead() + "/" + _in.getTotalExpanded());
|
||||
} catch (IOException ioe) {
|
||||
if (_log.shouldLog(Log.WARN))
|
||||
_log.warn("Error decompressing: " + written + ", " + (_in != null ? _in.getTotalRead() + "/" + _in.getTotalExpanded() : ""), ioe);
|
||||
_log.warn("Error decompressing: " + written + ", " + _in.getTotalRead() + "/" + _in.getTotalExpanded(), ioe);
|
||||
} catch (OutOfMemoryError oom) {
|
||||
_log.error("OOM in HTTP Decompressor", oom);
|
||||
} finally {
|
||||
|
@@ -51,6 +51,7 @@ import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import net.i2p.I2PAppContext;
|
||||
import net.i2p.I2PException;
|
||||
@@ -78,7 +79,7 @@ import net.i2p.util.Log;
|
||||
public class I2PTunnel extends EventDispatcherImpl implements Logging {
|
||||
private final Log _log;
|
||||
private final I2PAppContext _context;
|
||||
private static long __tunnelId = 0;
|
||||
private static final AtomicLong __tunnelId = new AtomicLong();
|
||||
private final long _tunnelId;
|
||||
private final Properties _clientOptions;
|
||||
private final Set<I2PSession> _sessions;
|
||||
@@ -118,7 +119,7 @@ public class I2PTunnel extends EventDispatcherImpl implements Logging {
|
||||
public I2PTunnel(String[] args, ConnectionEventListener lsnr) {
|
||||
super();
|
||||
_context = I2PAppContext.getGlobalContext(); // new I2PAppContext();
|
||||
_tunnelId = ++__tunnelId;
|
||||
_tunnelId = __tunnelId.incrementAndGet();
|
||||
_log = _context.logManager().getLog(I2PTunnel.class);
|
||||
// as of 0.8.4, include context properties
|
||||
Properties p = _context.getProperties();
|
||||
|
@@ -22,6 +22,7 @@ import java.util.concurrent.RejectedExecutionException;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import net.i2p.I2PAppContext;
|
||||
import net.i2p.I2PException;
|
||||
@@ -43,7 +44,7 @@ public abstract class I2PTunnelClientBase extends I2PTunnelTask implements Runna
|
||||
|
||||
static final long DEFAULT_CONNECT_TIMEOUT = 60 * 1000;
|
||||
|
||||
private static volatile long __clientId = 0;
|
||||
private static final AtomicLong __clientId = new AtomicLong();
|
||||
protected long _clientId;
|
||||
protected final Object sockLock = new Object(); // Guards sockMgr and mySockets
|
||||
protected I2PSocketManager sockMgr; // should be final and use a factory. LINT
|
||||
@@ -161,7 +162,7 @@ public abstract class I2PTunnelClientBase extends I2PTunnelTask implements Runna
|
||||
EventDispatcher notifyThis, String handlerName,
|
||||
I2PTunnel tunnel, String pkf) throws IllegalArgumentException{
|
||||
super(localPort + " (uninitialized)", notifyThis, tunnel);
|
||||
_clientId = ++__clientId;
|
||||
_clientId = __clientId.incrementAndGet();
|
||||
this.localPort = localPort;
|
||||
this.l = l;
|
||||
_ownDest = ownDest; // == ! shared client
|
||||
|
@@ -104,7 +104,7 @@ public class I2PTunnelConnectClient extends I2PTunnelHTTPClientBase implements R
|
||||
public I2PTunnelConnectClient(int localPort, Logging l, boolean ownDest,
|
||||
String wwwProxy, EventDispatcher notifyThis,
|
||||
I2PTunnel tunnel) throws IllegalArgumentException {
|
||||
super(localPort, ownDest, l, notifyThis, "HTTPS Proxy on " + tunnel.listenHost + ':' + localPort + " #" + (++__clientId), tunnel);
|
||||
super(localPort, ownDest, l, notifyThis, "HTTPS Proxy on " + tunnel.listenHost + ':' + localPort, tunnel);
|
||||
|
||||
if (waitEventValue("openBaseClientResult").equals("error")) {
|
||||
notifyEvent("openConnectClientResult", "error");
|
||||
@@ -167,7 +167,7 @@ public class I2PTunnelConnectClient extends I2PTunnelHTTPClientBase implements R
|
||||
String targetRequest = null;
|
||||
boolean usingWWWProxy = false;
|
||||
String currentProxy = null;
|
||||
long requestId = ++__requestId;
|
||||
long requestId = __requestId.incrementAndGet();
|
||||
try {
|
||||
out = s.getOutputStream();
|
||||
in = s.getInputStream();
|
||||
|
@@ -202,7 +202,7 @@ public class I2PTunnelHTTPClient extends I2PTunnelHTTPClientBase implements Runn
|
||||
public I2PTunnelHTTPClient(int localPort, Logging l, boolean ownDest,
|
||||
String wwwProxy, EventDispatcher notifyThis,
|
||||
I2PTunnel tunnel) throws IllegalArgumentException {
|
||||
super(localPort, ownDest, l, notifyThis, "HTTP Proxy on " + tunnel.listenHost + ':' + localPort + " #" + (++__clientId), tunnel);
|
||||
super(localPort, ownDest, l, notifyThis, "HTTP Proxy on " + tunnel.listenHost + ':' + localPort, tunnel);
|
||||
_proxyNonce = Long.toString(_context.random().nextLong());
|
||||
|
||||
//proxyList = new ArrayList(); // We won't use outside of i2p
|
||||
@@ -335,7 +335,7 @@ public class I2PTunnelHTTPClient extends I2PTunnelHTTPClientBase implements Runn
|
||||
String internalPath = null;
|
||||
String internalRawQuery = null;
|
||||
String currentProxy = null;
|
||||
long requestId = ++__requestId;
|
||||
long requestId = __requestId.incrementAndGet();
|
||||
boolean shout = false;
|
||||
|
||||
try {
|
||||
|
@@ -18,6 +18,7 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import net.i2p.I2PAppContext;
|
||||
import net.i2p.client.streaming.I2PSocketManager;
|
||||
@@ -69,9 +70,6 @@ public abstract class I2PTunnelHTTPClientBase extends I2PTunnelClientBase implem
|
||||
"HTTP outproxy configured. Please configure an outproxy in I2PTunnel")
|
||||
.getBytes();
|
||||
|
||||
/** used to assign unique IDs to the threads / clients. no logic or functionality */
|
||||
protected static volatile long __clientId = 0;
|
||||
|
||||
private final byte[] _proxyNonce;
|
||||
private final ConcurrentHashMap<String, NonceInfo> _nonces;
|
||||
private final AtomicInteger _nonceCleanCounter = new AtomicInteger();
|
||||
@@ -90,7 +88,7 @@ public abstract class I2PTunnelHTTPClientBase extends I2PTunnelClientBase implem
|
||||
|
||||
protected static final int DEFAULT_READ_TIMEOUT = 5*60*1000;
|
||||
|
||||
protected static long __requestId = 0;
|
||||
protected static final AtomicLong __requestId = new AtomicLong();
|
||||
|
||||
public I2PTunnelHTTPClientBase(int localPort, boolean ownDest, Logging l,
|
||||
EventDispatcher notifyThis, String handlerName,
|
||||
|
@@ -29,9 +29,6 @@ import net.i2p.util.PortMapper;
|
||||
*/
|
||||
public class I2PTunnelIRCClient extends I2PTunnelClientBase {
|
||||
|
||||
/** used to assign unique IDs to the threads / clients. no logic or functionality */
|
||||
private static volatile long __clientId = 0;
|
||||
|
||||
/** list of Destination objects that we point at */
|
||||
private final List<I2PSocketAddress> _addrs;
|
||||
private static final long DEFAULT_READ_TIMEOUT = 5*60*1000; // -1
|
||||
@@ -61,7 +58,7 @@ public class I2PTunnelIRCClient extends I2PTunnelClientBase {
|
||||
ownDest,
|
||||
l,
|
||||
notifyThis,
|
||||
"IRC Client on " + tunnel.listenHost + ':' + localPort + " #" + (++__clientId), tunnel, pkf);
|
||||
"IRC Client on " + tunnel.listenHost + ':' + localPort, tunnel, pkf);
|
||||
|
||||
_addrs = new ArrayList(4);
|
||||
buildAddresses(destinations);
|
||||
@@ -139,9 +136,9 @@ public class I2PTunnelIRCClient extends I2PTunnelClientBase {
|
||||
i2ps.setReadTimeout(readTimeout);
|
||||
StringBuffer expectedPong = new StringBuffer();
|
||||
DCCHelper dcc = _dccEnabled ? new DCC(s.getLocalAddress().getAddress()) : null;
|
||||
Thread in = new I2PAppThread(new IrcInboundFilter(s,i2ps, expectedPong, _log, dcc), "IRC Client " + __clientId + " in", true);
|
||||
Thread in = new I2PAppThread(new IrcInboundFilter(s,i2ps, expectedPong, _log, dcc), "IRC Client " + _clientId + " in", true);
|
||||
in.start();
|
||||
Thread out = new I2PAppThread(new IrcOutboundFilter(s,i2ps, expectedPong, _log, dcc), "IRC Client " + __clientId + " out", true);
|
||||
Thread out = new I2PAppThread(new IrcOutboundFilter(s,i2ps, expectedPong, _log, dcc), "IRC Client " + _clientId + " out", true);
|
||||
out.start();
|
||||
} catch (Exception ex) {
|
||||
// generally NoRouteToHostException
|
||||
|
@@ -11,6 +11,7 @@ import java.io.OutputStream;
|
||||
import java.net.Socket;
|
||||
import java.net.SocketException;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import javax.net.ssl.SSLException;
|
||||
|
||||
@@ -26,7 +27,7 @@ import net.i2p.util.Log;
|
||||
public class I2PTunnelRunner extends I2PAppThread implements I2PSocket.SocketErrorListener {
|
||||
protected final Log _log;
|
||||
|
||||
private static volatile long __runnerId;
|
||||
private static final AtomicLong __runnerId = new AtomicLong();
|
||||
private final long _runnerId;
|
||||
/**
|
||||
* max bytes streamed in a packet - smaller ones might be filled
|
||||
@@ -96,7 +97,7 @@ public class I2PTunnelRunner extends I2PAppThread implements I2PSocket.SocketErr
|
||||
_log = I2PAppContext.getGlobalContext().logManager().getLog(getClass());
|
||||
if (_log.shouldLog(Log.INFO))
|
||||
_log.info("I2PTunnelRunner started");
|
||||
_runnerId = ++__runnerId;
|
||||
_runnerId = __runnerId.incrementAndGet();
|
||||
__forwarderId = i2ps.hashCode();
|
||||
setName("I2PTunnelRunner " + _runnerId);
|
||||
start();
|
||||
|
@@ -6,6 +6,7 @@ package net.i2p.i2ptunnel.udpTunnel;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.net.ServerSocket;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import net.i2p.I2PAppContext;
|
||||
import net.i2p.client.I2PClient;
|
||||
@@ -48,13 +49,12 @@ import net.i2p.util.EventDispatcher;
|
||||
|
||||
static final long DEFAULT_CONNECT_TIMEOUT = 60 * 1000;
|
||||
|
||||
private static volatile long __clientId = 0;
|
||||
private static final AtomicLong __clientId = new AtomicLong();
|
||||
protected long _clientId;
|
||||
|
||||
protected Destination dest = null;
|
||||
|
||||
private final Object startLock = new Object();
|
||||
private Object conLock = new Object();
|
||||
|
||||
private I2PSession _session;
|
||||
private Source _i2pSource;
|
||||
@@ -67,7 +67,7 @@ import net.i2p.util.EventDispatcher;
|
||||
public I2PTunnelUDPClientBase(String destination, Logging l, EventDispatcher notifyThis,
|
||||
I2PTunnel tunnel) throws IllegalArgumentException {
|
||||
super("UDPServer", notifyThis, tunnel);
|
||||
_clientId = ++__clientId;
|
||||
_clientId = __clientId.incrementAndGet();;
|
||||
this.l = l;
|
||||
|
||||
_context = tunnel.getContext();
|
||||
|
Reference in New Issue
Block a user