lint redundant cast all over

This commit is contained in:
zzz
2014-06-26 15:26:58 +00:00
parent bc99bc7206
commit ca4555c496
21 changed files with 36 additions and 38 deletions

View File

@ -78,7 +78,7 @@ public class ConfigurationManager {
* @return The value of a configuration: true if found, defaultValue if not found. * @return The value of a configuration: true if found, defaultValue if not found.
*/ */
public boolean getBooleanConfiguration(String arg, boolean defaultValue) { public boolean getBooleanConfiguration(String arg, boolean defaultValue) {
Boolean value = ((Boolean) booleanConfigurations.get("startWithI2P")); Boolean value = booleanConfigurations.get("startWithI2P");
System.out.println(value); System.out.println(value);
if(value != null) { if(value != null) {
return value; return value;

View File

@ -194,9 +194,8 @@ public class Peer implements Comparable<Peer>
* Compares the PeerIDs. * Compares the PeerIDs.
* @deprecated unused? * @deprecated unused?
*/ */
public int compareTo(Peer o) public int compareTo(Peer p)
{ {
Peer p = (Peer)o;
int rv = peerID.compareTo(p.peerID); int rv = peerID.compareTo(p.peerID);
if (rv == 0) { if (rv == 0) {
if (_id > p._id) return 1; if (_id > p._id) return 1;

View File

@ -62,7 +62,7 @@ class TrackerInfo
private TrackerInfo(Map<String, BEValue> m, byte[] my_id, byte[] infohash, MetaInfo metainfo, I2PSnarkUtil util) private TrackerInfo(Map<String, BEValue> m, byte[] my_id, byte[] infohash, MetaInfo metainfo, I2PSnarkUtil util)
throws IOException throws IOException
{ {
BEValue reason = (BEValue)m.get("failure reason"); BEValue reason = m.get("failure reason");
if (reason != null) if (reason != null)
{ {
failure_reason = reason.getString(); failure_reason = reason.getString();
@ -72,13 +72,13 @@ class TrackerInfo
else else
{ {
failure_reason = null; failure_reason = null;
BEValue beInterval = (BEValue)m.get("interval"); BEValue beInterval = m.get("interval");
if (beInterval == null) if (beInterval == null)
throw new InvalidBEncodingException("No interval given"); throw new InvalidBEncodingException("No interval given");
else else
interval = beInterval.getInt(); interval = beInterval.getInt();
BEValue bePeers = (BEValue)m.get("peers"); BEValue bePeers = m.get("peers");
if (bePeers == null) { if (bePeers == null) {
peers = Collections.emptySet(); peers = Collections.emptySet();
} else { } else {
@ -93,14 +93,14 @@ class TrackerInfo
peers = p; peers = p;
} }
BEValue bev = (BEValue)m.get("complete"); BEValue bev = m.get("complete");
if (bev != null) try { if (bev != null) try {
complete = bev.getInt(); complete = bev.getInt();
if (complete < 0) if (complete < 0)
complete = 0; complete = 0;
} catch (InvalidBEncodingException ibe) {} } catch (InvalidBEncodingException ibe) {}
bev = (BEValue)m.get("incomplete"); bev = m.get("incomplete");
if (bev != null) try { if (bev != null) try {
incomplete = bev.getInt(); incomplete = bev.getInt();
if (incomplete < 0) if (incomplete < 0)

View File

@ -204,8 +204,7 @@ public class I2PSnarkServlet extends BasicServlet {
resp.sendError(404); resp.sendError(404);
} else { } else {
String base = addPaths(req.getRequestURI(), "/"); String base = addPaths(req.getRequestURI(), "/");
@SuppressWarnings("unchecked") // TODO-Java6: Remove cast, return type is correct String listing = getListHTML(resource, base, true, method.equals("POST") ? req.getParameterMap() : null);
String listing = getListHTML(resource, base, true, method.equals("POST") ? (Map<String, String[]>) req.getParameterMap() : null);
if (method.equals("POST")) { if (method.equals("POST")) {
// P-R-G // P-R-G
sendRedirect(req, resp, ""); sendRedirect(req, resp, "");
@ -547,7 +546,7 @@ public class I2PSnarkServlet extends BasicServlet {
String stParamStr = stParam == null ? "" : "&amp;st=" + stParam; String stParamStr = stParam == null ? "" : "&amp;st=" + stParam;
for (int i = 0; i < total; i++) { for (int i = 0; i < total; i++) {
Snark snark = (Snark)snarks.get(i); Snark snark = snarks.get(i);
boolean showPeers = showDebug || "1".equals(peerParam) || Base64.encode(snark.getInfoHash()).equals(peerParam); boolean showPeers = showDebug || "1".equals(peerParam) || Base64.encode(snark.getInfoHash()).equals(peerParam);
boolean hide = i < start || i >= start + pageSize; boolean hide = i < start || i >= start + pageSize;
displaySnark(out, snark, uri, i, stats, showPeers, isDegraded, noThinsp, showDebug, hide, stParamStr); displaySnark(out, snark, uri, i, stats, showPeers, isDegraded, noThinsp, showDebug, hide, stParamStr);

View File

@ -78,7 +78,7 @@ public class TunnelRenderer {
int inactive = 0; int inactive = 0;
int displayed = 0; int displayed = 0;
for (int i = 0; i < participating.size(); i++) { for (int i = 0; i < participating.size(); i++) {
HopConfig cfg = (HopConfig)participating.get(i); HopConfig cfg = participating.get(i);
long count = cfg.getProcessedMessagesCount(); long count = cfg.getProcessedMessagesCount();
if (count <= 0) { if (count <= 0) {
inactive++; inactive++;

View File

@ -216,7 +216,7 @@ class PacketQueue implements SendMessageStatusListener {
_connectionManager.getPacketHandler().displayPacket(packet, "SEND", suffix); _connectionManager.getPacketHandler().displayPacket(packet, "SEND", suffix);
if (I2PSocketManagerFull.pcapWriter != null && if (I2PSocketManagerFull.pcapWriter != null &&
_context.getBooleanProperty(I2PSocketManagerFull.PROP_PCAP)) _context.getBooleanProperty(I2PSocketManagerFull.PROP_PCAP))
((PacketLocal)packet).logTCPDump(); packet.logTCPDump();
} }
if ( (packet.getSequenceNum() == 0) && (!packet.isFlagSet(Packet.FLAG_SYNCHRONIZE)) ) { if ( (packet.getSequenceNum() == 0) && (!packet.isFlagSet(Packet.FLAG_SYNCHRONIZE)) ) {

View File

@ -154,7 +154,7 @@ class RequestWrapper {
{ {
String result = defaultValue; String result = defaultValue;
if( multiPartRequest != null ) { if( multiPartRequest != null ) {
String str = (String)cache.get( name ); String str = cache.get(name);
if( str != null ) { if( str != null ) {
result = str; result = str;
} }

View File

@ -1211,7 +1211,7 @@ public class WebMail extends HttpServlet
for (Integer item : getCheckedItems(request)) { for (Integer item : getCheckedItems(request)) {
int n = item.intValue(); int n = item.intValue();
for( int i = 0; i < sessionObject.attachments.size(); i++ ) { for( int i = 0; i < sessionObject.attachments.size(); i++ ) {
Attachment attachment = (Attachment)sessionObject.attachments.get( i ); Attachment attachment = sessionObject.attachments.get(i);
if( attachment.hashCode() == n ) { if( attachment.hashCode() == n ) {
sessionObject.attachments.remove( i ); sessionObject.attachments.remove( i );
break; break;

View File

@ -290,7 +290,7 @@ public class MultiPartRequest
{ {
String key = line.substring(0,c).trim().toLowerCase(); String key = line.substring(0,c).trim().toLowerCase();
String value = line.substring(c+1,line.length()).trim(); String value = line.substring(c+1,line.length()).trim();
String ev = (String) part._headers.get(key); String ev = part._headers.get(key);
part._headers.put(key,(ev!=null)?(ev+';'+value):value); part._headers.put(key,(ev!=null)?(ev+';'+value):value);
//if(log.isDebugEnabled())log.debug(key+": "+value); //if(log.isDebugEnabled())log.debug(key+": "+value);
if (key.equals("content-disposition")) if (key.equals("content-disposition"))

View File

@ -317,7 +317,7 @@ public class FortunaStandalone extends BasePRNGStandalone implements Serializabl
seeded = false; seeded = false;
Arrays.fill(key, (byte) 0); Arrays.fill(key, (byte) 0);
Arrays.fill(counter, (byte) 0); Arrays.fill(counter, (byte) 0);
byte[] seed = (byte[]) attributes.get(SEED); byte[] seed = attributes.get(SEED);
if (seed != null) if (seed != null)
addRandomBytes(seed); addRandomBytes(seed);
} }

View File

@ -85,7 +85,7 @@ public class EepGetNamingService extends DummyNamingService {
// lookup // lookup
for (int i = 0; i < URLs.size(); i++) { for (int i = 0; i < URLs.size(); i++) {
String url = (String)URLs.get(i); String url = URLs.get(i);
String key = fetchAddr(url, hostname); String key = fetchAddr(url, hostname);
if (key != null) { if (key != null) {
_log.error("Success: " + url + hostname); _log.error("Success: " + url + hostname);

View File

@ -425,7 +425,7 @@ public class BlockFile {
*/ */
public BSkipList getIndex(String name, Serializer key, Serializer val) throws IOException { public BSkipList getIndex(String name, Serializer key, Serializer val) throws IOException {
// added I2P // added I2P
BSkipList bsl = (BSkipList) openIndices.get(name); BSkipList bsl = openIndices.get(name);
if (bsl != null) if (bsl != null)
return bsl; return bsl;
@ -465,7 +465,7 @@ public class BlockFile {
* Added I2P * Added I2P
*/ */
public void closeIndex(String name) { public void closeIndex(String name) {
BSkipList bsl = (BSkipList) openIndices.remove(name); BSkipList bsl = openIndices.remove(name);
if (bsl != null) if (bsl != null)
bsl.flush(); bsl.flush();
} }

View File

@ -379,8 +379,8 @@ public class InNetMessagePool implements Service {
Hash from = null; Hash from = null;
synchronized (_pendingDataMessages) { synchronized (_pendingDataMessages) {
if (!_pendingDataMessages.isEmpty()) { if (!_pendingDataMessages.isEmpty()) {
msg = (I2NPMessage)_pendingDataMessages.remove(0); msg = _pendingDataMessages.remove(0);
from = (Hash)_pendingDataMessagesFrom.remove(0); from = _pendingDataMessagesFrom.remove(0);
} }
remaining = _pendingDataMessages.size(); remaining = _pendingDataMessages.size();
} }
@ -402,7 +402,7 @@ public class InNetMessagePool implements Service {
int remaining = 0; int remaining = 0;
synchronized (_pendingGatewayMessages) { synchronized (_pendingGatewayMessages) {
if (!_pendingGatewayMessages.isEmpty()) if (!_pendingGatewayMessages.isEmpty())
msg = (I2NPMessage)_pendingGatewayMessages.remove(0); msg = _pendingGatewayMessages.remove(0);
remaining = _pendingGatewayMessages.size(); remaining = _pendingGatewayMessages.size();
} }
if (msg != null) if (msg != null)
@ -422,7 +422,7 @@ public class InNetMessagePool implements Service {
if (_pendingGatewayMessages.isEmpty()) if (_pendingGatewayMessages.isEmpty())
_pendingGatewayMessages.wait(); _pendingGatewayMessages.wait();
else else
msg = (I2NPMessage)_pendingGatewayMessages.remove(0); msg = _pendingGatewayMessages.remove(0);
} }
if (msg != null) { if (msg != null) {
long before = _context.clock().now(); long before = _context.clock().now();
@ -453,8 +453,8 @@ public class InNetMessagePool implements Service {
if (_pendingDataMessages.isEmpty()) { if (_pendingDataMessages.isEmpty()) {
_pendingDataMessages.wait(); _pendingDataMessages.wait();
} else { } else {
msg = (I2NPMessage)_pendingDataMessages.remove(0); msg = _pendingDataMessages.remove(0);
from = (Hash)_pendingDataMessagesFrom.remove(0); from = _pendingDataMessagesFrom.remove(0);
} }
} }
if (msg != null) { if (msg != null) {

View File

@ -240,7 +240,7 @@ public class MultiRouter {
while (true) { while (true) {
int alive = 0; int alive = 0;
for (int i = 0; i < _routers.size(); i++) { for (int i = 0; i < _routers.size(); i++) {
Router r = (Router)_routers.get(i); Router r = _routers.get(i);
if (!r.isAlive()) { if (!r.isAlive()) {
_out.println("Router " + i + " is dead"); _out.println("Router " + i + " is dead");
} else { } else {

View File

@ -49,12 +49,12 @@ public class DummyNetworkDatabaseFacade extends NetworkDatabaseFacade {
else else
_context.jobQueue().addJob(onFindJob); _context.jobQueue().addJob(onFindJob);
} }
public RouterInfo lookupRouterInfoLocally(Hash key) { return (RouterInfo)_routers.get(key); } public RouterInfo lookupRouterInfoLocally(Hash key) { return _routers.get(key); }
public void publish(LeaseSet localLeaseSet) {} public void publish(LeaseSet localLeaseSet) {}
public void publish(RouterInfo localRouterInfo) {} public void publish(RouterInfo localRouterInfo) {}
public LeaseSet store(Hash key, LeaseSet leaseSet) { return leaseSet; } public LeaseSet store(Hash key, LeaseSet leaseSet) { return leaseSet; }
public RouterInfo store(Hash key, RouterInfo routerInfo) { public RouterInfo store(Hash key, RouterInfo routerInfo) {
RouterInfo rv = (RouterInfo)_routers.put(key, routerInfo); RouterInfo rv = _routers.put(key, routerInfo);
return rv; return rv;
} }
public void unpublish(LeaseSet localLeaseSet) {} public void unpublish(LeaseSet localLeaseSet) {}

View File

@ -52,7 +52,7 @@ public class VMCommSystem extends CommSystemFacade {
*/ */
public void processMessage(OutNetMessage msg) { public void processMessage(OutNetMessage msg) {
Hash peer = msg.getTarget().getIdentity().getHash(); Hash peer = msg.getTarget().getIdentity().getHash();
VMCommSystem peerSys = (VMCommSystem)_commSystemFacades.get(peer); VMCommSystem peerSys = _commSystemFacades.get(peer);
long now = _context.clock().now(); long now = _context.clock().now();
long sendTime = now - msg.getSendBegin(); long sendTime = now - msg.getSendBegin();

View File

@ -43,7 +43,7 @@ public class LoadClientAppsJob extends JobImpl {
return; return;
} }
for(int i = 0; i < apps.size(); i++) { for(int i = 0; i < apps.size(); i++) {
ClientAppConfig app = (ClientAppConfig) apps.get(i); ClientAppConfig app = apps.get(i);
if (app.disabled) { if (app.disabled) {
if ("net.i2p.router.web.RouterConsoleRunner".equals(app.className)) { if ("net.i2p.router.web.RouterConsoleRunner".equals(app.className)) {
String s = "Warning - Router console is disabled. To enable,\n edit the file " + String s = "Warning - Router console is disabled. To enable,\n edit the file " +

View File

@ -70,7 +70,7 @@ class NtpClient {
names.add(serverNames[i]); names.add(serverNames[i]);
Collections.shuffle(names); Collections.shuffle(names);
for (int i = 0; i < names.size(); i++) { for (int i = 0; i < names.size(); i++) {
long now = currentTime((String)names.get(i)); long now = currentTime(names.get(i));
if (now > 0) if (now > 0)
return now; return now;
} }
@ -92,7 +92,7 @@ class NtpClient {
names.add(serverNames[i]); names.add(serverNames[i]);
Collections.shuffle(names); Collections.shuffle(names);
for (int i = 0; i < names.size(); i++) { for (int i = 0; i < names.size(); i++) {
long[] rv = currentTimeAndStratum((String)names.get(i)); long[] rv = currentTimeAndStratum(names.get(i));
if (rv != null && rv[0] > 0) if (rv != null && rv[0] > 0)
return rv; return rv;
} }

View File

@ -115,7 +115,7 @@ public class CommSystemFacadeImpl extends CommSystemFacade {
// Sum skew values // Sum skew values
long sum = 0; long sum = 0;
for (int i = first; i <= last; i++) { for (int i = first; i <= last; i++) {
long value = ((Long) (skews.get(i))).longValue(); long value = skews.get(i).longValue();
//if (_log.shouldLog(Log.DEBUG)) //if (_log.shouldLog(Log.DEBUG))
// _log.debug("Adding clock skew " + i + " valued " + value + " s."); // _log.debug("Adding clock skew " + i + " valued " + value + " s.");
sum = sum + value; sum = sum + value;

View File

@ -124,7 +124,7 @@ class TimedWeightedPriorityMessageQueue implements MessageQueue, OutboundMessage
int currentQueue = (_nextQueue + i) % _queue.length; int currentQueue = (_nextQueue + i) % _queue.length;
synchronized (_queue[currentQueue]) { synchronized (_queue[currentQueue]) {
for (int j = 0; j < _queue[currentQueue].size(); j++) { for (int j = 0; j < _queue[currentQueue].size(); j++) {
OutNetMessage msg = (OutNetMessage)_queue[currentQueue].get(j); OutNetMessage msg = _queue[currentQueue].get(j);
Hash to = msg.getTarget().getIdentity().getHash(); Hash to = msg.getTarget().getIdentity().getHash();
if (_chokedPeers.contains(to)) if (_chokedPeers.contains(to))
continue; continue;
@ -239,7 +239,7 @@ class TimedWeightedPriorityMessageQueue implements MessageQueue, OutboundMessage
for (int i = 0; i < _queue.length; i++) { for (int i = 0; i < _queue.length; i++) {
synchronized (_queue[i]) { synchronized (_queue[i]) {
for (int j = 0; j < _queue[i].size(); j++) { for (int j = 0; j < _queue[i].size(); j++) {
OutNetMessage m = (OutNetMessage)_queue[i].get(j); OutNetMessage m = _queue[i].get(j);
if (m.getExpiration() < now) { if (m.getExpiration() < now) {
_bytesQueued[i] -= m.getMessageSize(); _bytesQueued[i] -= m.getMessageSize();
removed.add(m); removed.add(m);
@ -252,7 +252,7 @@ class TimedWeightedPriorityMessageQueue implements MessageQueue, OutboundMessage
} }
for (int i = 0; i < removed.size(); i++) { for (int i = 0; i < removed.size(); i++) {
OutNetMessage m = (OutNetMessage)removed.get(i); OutNetMessage m = removed.get(i);
m.timestamp("expirer killed it"); m.timestamp("expirer killed it");
_listener.failed(m, "expired before getting on the active pool"); _listener.failed(m, "expired before getting on the active pool");
} }

View File

@ -152,7 +152,7 @@ public abstract class BuildMessageGenerator {
// encrypt the records so that the right elements will be visible at the right time // encrypt the records so that the right elements will be visible at the right time
for (int i = 0; i < msg.getRecordCount(); i++) { for (int i = 0; i < msg.getRecordCount(); i++) {
ByteArray rec = msg.getRecord(i); ByteArray rec = msg.getRecord(i);
Integer hopNum = (Integer)order.get(i); Integer hopNum = order.get(i);
int hop = hopNum.intValue(); int hop = hopNum.intValue();
if ( (isBlank(cfg, hop)) || (!cfg.isInbound() && hop == 1) ) { if ( (isBlank(cfg, hop)) || (!cfg.isInbound() && hop == 1) ) {
//if (log.shouldLog(Log.DEBUG)) //if (log.shouldLog(Log.DEBUG))