forked from I2P_Developers/i2p.i2p
lint core, i2psnark, jetty, susimail
This commit is contained in:
@ -136,6 +136,7 @@ public class I2PSnarkUtil {
|
|||||||
|
|
||||||
public boolean configured() { return _configured; }
|
public boolean configured() { return _configured; }
|
||||||
|
|
||||||
|
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||||
public void setI2CPConfig(String i2cpHost, int i2cpPort, Map opts) {
|
public void setI2CPConfig(String i2cpHost, int i2cpPort, Map opts) {
|
||||||
if (i2cpHost != null)
|
if (i2cpHost != null)
|
||||||
_i2cpHost = i2cpHost;
|
_i2cpHost = i2cpHost;
|
||||||
|
@ -2191,7 +2191,7 @@ public class SnarkManager implements CompleteListener {
|
|||||||
*/
|
*/
|
||||||
private void addMagnets() {
|
private void addMagnets() {
|
||||||
boolean changed = false;
|
boolean changed = false;
|
||||||
for (Iterator iter = _config.keySet().iterator(); iter.hasNext(); ) {
|
for (Iterator<?> iter = _config.keySet().iterator(); iter.hasNext(); ) {
|
||||||
String k = (String) iter.next();
|
String k = (String) iter.next();
|
||||||
if (k.startsWith(PROP_META_MAGNET_PREFIX)) {
|
if (k.startsWith(PROP_META_MAGNET_PREFIX)) {
|
||||||
String b64 = k.substring(PROP_META_MAGNET_PREFIX.length());
|
String b64 = k.substring(PROP_META_MAGNET_PREFIX.length());
|
||||||
|
@ -106,6 +106,7 @@ class DHTTracker {
|
|||||||
* @param noSeeds true if we do not want seeds in the result
|
* @param noSeeds true if we do not want seeds in the result
|
||||||
* @return list or empty list (never null)
|
* @return list or empty list (never null)
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||||
List<Hash> getPeers(InfoHash ih, int max, boolean noSeeds) {
|
List<Hash> getPeers(InfoHash ih, int max, boolean noSeeds) {
|
||||||
Peers peers = _torrents.get(ih);
|
Peers peers = _torrents.get(ih);
|
||||||
if (peers == null || max <= 0)
|
if (peers == null || max <= 0)
|
||||||
|
@ -243,6 +243,7 @@ public class KRPC implements I2PSessionMuxedListener, DHT {
|
|||||||
* @param maxWait how long to wait for each to reply (not total) must be > 0
|
* @param maxWait how long to wait for each to reply (not total) must be > 0
|
||||||
* @param parallel how many outstanding at once (unimplemented, always 1)
|
* @param parallel how many outstanding at once (unimplemented, always 1)
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
private void explore(NID target, int maxNodes, long maxWait, int parallel) {
|
private void explore(NID target, int maxNodes, long maxWait, int parallel) {
|
||||||
List<NodeInfo> nodes = _knownNodes.findClosest(target, maxNodes);
|
List<NodeInfo> nodes = _knownNodes.findClosest(target, maxNodes);
|
||||||
if (nodes.isEmpty()) {
|
if (nodes.isEmpty()) {
|
||||||
@ -327,6 +328,7 @@ public class KRPC implements I2PSessionMuxedListener, DHT {
|
|||||||
* @param noSeeds true if we do not want seeds in the result
|
* @param noSeeds true if we do not want seeds in the result
|
||||||
* @return possibly empty (never null)
|
* @return possibly empty (never null)
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public Collection<Hash> getPeersAndAnnounce(byte[] ih, int max, long maxWait,
|
public Collection<Hash> getPeersAndAnnounce(byte[] ih, int max, long maxWait,
|
||||||
int annMax, long annMaxWait,
|
int annMax, long annMaxWait,
|
||||||
boolean isSeed, boolean noSeeds) {
|
boolean isSeed, boolean noSeeds) {
|
||||||
@ -858,6 +860,7 @@ public class KRPC implements I2PSessionMuxedListener, DHT {
|
|||||||
* @param repliable true for all but announce
|
* @param repliable true for all but announce
|
||||||
* @return null on error
|
* @return null on error
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
private ReplyWaiter sendQuery(NodeInfo nInfo, Map<String, Object> map, boolean repliable) {
|
private ReplyWaiter sendQuery(NodeInfo nInfo, Map<String, Object> map, boolean repliable) {
|
||||||
if (nInfo.equals(_myNodeInfo))
|
if (nInfo.equals(_myNodeInfo))
|
||||||
throw new IllegalArgumentException("wtf don't send to ourselves");
|
throw new IllegalArgumentException("wtf don't send to ourselves");
|
||||||
@ -907,6 +910,7 @@ public class KRPC implements I2PSessionMuxedListener, DHT {
|
|||||||
* @param toPort the query port, we will increment here
|
* @param toPort the query port, we will increment here
|
||||||
* @return success
|
* @return success
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
private boolean sendResponse(NodeInfo nInfo, MsgID msgID, Map<String, Object> map) {
|
private boolean sendResponse(NodeInfo nInfo, MsgID msgID, Map<String, Object> map) {
|
||||||
if (nInfo.equals(_myNodeInfo))
|
if (nInfo.equals(_myNodeInfo))
|
||||||
throw new IllegalArgumentException("wtf don't send to ourselves");
|
throw new IllegalArgumentException("wtf don't send to ourselves");
|
||||||
|
@ -72,6 +72,7 @@ public class JettyStart implements ClientApp {
|
|||||||
/**
|
/**
|
||||||
* Modified from XmlConfiguration.main()
|
* Modified from XmlConfiguration.main()
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||||
public void parseArgs(String[] args) throws Exception {
|
public void parseArgs(String[] args) throws Exception {
|
||||||
Properties properties=new Properties();
|
Properties properties=new Properties();
|
||||||
XmlConfiguration last=null;
|
XmlConfiguration last=null;
|
||||||
|
@ -84,6 +84,7 @@ public class XSSRequestWrapper extends HttpServletRequestWrapper {
|
|||||||
* Parameter names starting with "nofilter_" will not be filtered.
|
* Parameter names starting with "nofilter_" will not be filtered.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||||
public Map getParameterMap() {
|
public Map getParameterMap() {
|
||||||
Map rv = new HashMap();
|
Map rv = new HashMap();
|
||||||
for (Enumeration keys = getParameterNames(); keys.hasMoreElements(); ) {
|
for (Enumeration keys = getParameterNames(); keys.hasMoreElements(); ) {
|
||||||
|
@ -219,6 +219,7 @@ public class MultiPartRequest
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
public Hashtable[] getMultipleParams(String name)
|
public Hashtable[] getMultipleParams(String name)
|
||||||
{
|
{
|
||||||
List<Object> parts = _partMap.getValues(name);
|
List<Object> parts = _partMap.getValues(name);
|
||||||
|
@ -29,7 +29,7 @@ public class ByteArrayPool
|
|||||||
public static final int __POOL_SIZE=
|
public static final int __POOL_SIZE=
|
||||||
Integer.getInteger("org.mortbay.util.ByteArrayPool.pool_size",8).intValue();
|
Integer.getInteger("org.mortbay.util.ByteArrayPool.pool_size",8).intValue();
|
||||||
|
|
||||||
public static final ThreadLocal __pools=new BAThreadLocal();
|
public static final ThreadLocal<byte[][]> __pools = new BAThreadLocal();
|
||||||
public static final AtomicInteger __slot = new AtomicInteger();
|
public static final AtomicInteger __slot = new AtomicInteger();
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
@ -39,7 +39,7 @@ public class ByteArrayPool
|
|||||||
*/
|
*/
|
||||||
public static byte[] getByteArray(int size)
|
public static byte[] getByteArray(int size)
|
||||||
{
|
{
|
||||||
byte[][] pool = (byte[][])__pools.get();
|
byte[][] pool = __pools.get();
|
||||||
boolean full=true;
|
boolean full=true;
|
||||||
for (int i=pool.length;i-->0;)
|
for (int i=pool.length;i-->0;)
|
||||||
{
|
{
|
||||||
@ -63,7 +63,7 @@ public class ByteArrayPool
|
|||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
public static byte[] getByteArrayAtLeast(int minSize)
|
public static byte[] getByteArrayAtLeast(int minSize)
|
||||||
{
|
{
|
||||||
byte[][] pool = (byte[][])__pools.get();
|
byte[][] pool = __pools.get();
|
||||||
for (int i=pool.length;i-->0;)
|
for (int i=pool.length;i-->0;)
|
||||||
{
|
{
|
||||||
if (pool[i]!=null && pool[i].length>=minSize)
|
if (pool[i]!=null && pool[i].length>=minSize)
|
||||||
@ -84,7 +84,7 @@ public class ByteArrayPool
|
|||||||
if (b==null)
|
if (b==null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
byte[][] pool = (byte[][])__pools.get();
|
byte[][] pool = __pools.get();
|
||||||
for (int i=pool.length;i-->0;)
|
for (int i=pool.length;i-->0;)
|
||||||
{
|
{
|
||||||
if (pool[i]==null)
|
if (pool[i]==null)
|
||||||
@ -103,9 +103,10 @@ public class ByteArrayPool
|
|||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
private static final class BAThreadLocal extends ThreadLocal
|
private static final class BAThreadLocal extends ThreadLocal<byte[][]>
|
||||||
{
|
{
|
||||||
protected Object initialValue()
|
@Override
|
||||||
|
protected byte[][] initialValue()
|
||||||
{
|
{
|
||||||
return new byte[__POOL_SIZE][];
|
return new byte[__POOL_SIZE][];
|
||||||
}
|
}
|
||||||
|
@ -109,6 +109,7 @@ class MailCache {
|
|||||||
* @param mode CACHE_ONLY to not pull from pop server
|
* @param mode CACHE_ONLY to not pull from pop server
|
||||||
* @return An e-mail or null
|
* @return An e-mail or null
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||||
public Mail getMail(String uidl, FetchMode mode) {
|
public Mail getMail(String uidl, FetchMode mode) {
|
||||||
|
|
||||||
Mail mail = null, newMail = null;
|
Mail mail = null, newMail = null;
|
||||||
@ -163,6 +164,7 @@ class MailCache {
|
|||||||
* @return true if any were fetched
|
* @return true if any were fetched
|
||||||
* @since 0.9.13
|
* @since 0.9.13
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||||
public boolean getMail(FetchMode mode) {
|
public boolean getMail(FetchMode mode) {
|
||||||
if (mode == FetchMode.CACHE_ONLY)
|
if (mode == FetchMode.CACHE_ONLY)
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
|
@ -288,7 +288,7 @@ public class WebMail extends HttpServlet
|
|||||||
*/
|
*/
|
||||||
private static class SenderSorter extends SorterBase {
|
private static class SenderSorter extends SorterBase {
|
||||||
|
|
||||||
private final Comparator collator = Collator.getInstance();
|
private final Comparator<Object> collator = Collator.getInstance();
|
||||||
|
|
||||||
public SenderSorter( MailCache mailCache )
|
public SenderSorter( MailCache mailCache )
|
||||||
{
|
{
|
||||||
@ -307,7 +307,7 @@ public class WebMail extends HttpServlet
|
|||||||
* @author susi
|
* @author susi
|
||||||
*/
|
*/
|
||||||
private static class SubjectSorter extends SorterBase {
|
private static class SubjectSorter extends SorterBase {
|
||||||
private final Comparator collator = Collator.getInstance();
|
private final Comparator<Object> collator = Collator.getInstance();
|
||||||
|
|
||||||
public SubjectSorter( MailCache mailCache )
|
public SubjectSorter( MailCache mailCache )
|
||||||
{
|
{
|
||||||
@ -2299,7 +2299,7 @@ public class WebMail extends HttpServlet
|
|||||||
/**
|
/**
|
||||||
* first prev next last
|
* first prev next last
|
||||||
*/
|
*/
|
||||||
private static void showPageButtons(PrintWriter out, Folder folder) {
|
private static void showPageButtons(PrintWriter out, Folder<?> folder) {
|
||||||
out.println(
|
out.println(
|
||||||
"<br>" +
|
"<br>" +
|
||||||
( folder.isFirstPage() ?
|
( folder.isFirstPage() ?
|
||||||
|
@ -41,8 +41,8 @@ public class MetaNamingService extends DummyNamingService {
|
|||||||
while (tok.hasMoreTokens()) {
|
while (tok.hasMoreTokens()) {
|
||||||
try {
|
try {
|
||||||
Class<?> cls = Class.forName(tok.nextToken());
|
Class<?> cls = Class.forName(tok.nextToken());
|
||||||
Constructor<?> con = cls.getConstructor(new Class[] { I2PAppContext.class });
|
Constructor<?> con = cls.getConstructor(I2PAppContext.class);
|
||||||
addNamingService((NamingService)con.newInstance(new Object[] { context }), false);
|
addNamingService((NamingService)con.newInstance(), false);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -537,7 +537,7 @@ public abstract class NamingService {
|
|||||||
try {
|
try {
|
||||||
Class<?> cls = Class.forName(impl);
|
Class<?> cls = Class.forName(impl);
|
||||||
Constructor<?> con = cls.getConstructor(I2PAppContext.class);
|
Constructor<?> con = cls.getConstructor(I2PAppContext.class);
|
||||||
instance = (NamingService)con.newInstance(new Object[] { context });
|
instance = (NamingService)con.newInstance(context);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
Log log = context.logManager().getLog(NamingService.class);
|
Log log = context.logManager().getLog(NamingService.class);
|
||||||
// Blockfile may throw RuntimeException but HostsTxt won't
|
// Blockfile may throw RuntimeException but HostsTxt won't
|
||||||
|
@ -92,8 +92,8 @@ public class CryptoConstants {
|
|||||||
if (ECConstants.isBCAvailable()) {
|
if (ECConstants.isBCAvailable()) {
|
||||||
try {
|
try {
|
||||||
Class<?> cls = Class.forName("org.bouncycastle.jce.spec.ElGamalParameterSpec");
|
Class<?> cls = Class.forName("org.bouncycastle.jce.spec.ElGamalParameterSpec");
|
||||||
Constructor<?> con = cls.getConstructor(new Class[] {BigInteger.class, BigInteger.class});
|
Constructor<?> con = cls.getConstructor(BigInteger.class, BigInteger.class);
|
||||||
spec = (AlgorithmParameterSpec)con.newInstance(new Object[] {elgp, elgg});
|
spec = (AlgorithmParameterSpec)con.newInstance(elgp, elgg);
|
||||||
//System.out.println("BC ElG spec loaded");
|
//System.out.println("BC ElG spec loaded");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
//System.out.println("BC ElG spec failed");
|
//System.out.println("BC ElG spec failed");
|
||||||
|
@ -42,8 +42,8 @@ class ECConstants {
|
|||||||
if (Security.getProvider("BC") == null) {
|
if (Security.getProvider("BC") == null) {
|
||||||
try {
|
try {
|
||||||
Class<?> cls = Class.forName("org.bouncycastle.jce.provider.BouncyCastleProvider");
|
Class<?> cls = Class.forName("org.bouncycastle.jce.provider.BouncyCastleProvider");
|
||||||
Constructor<?> con = cls.getConstructor(new Class[0]);
|
Constructor<?> con = cls.getConstructor();
|
||||||
Provider bc = (Provider)con.newInstance(new Object[0]);
|
Provider bc = (Provider)con.newInstance();
|
||||||
Security.addProvider(bc);
|
Security.addProvider(bc);
|
||||||
log("Added BC provider");
|
log("Added BC provider");
|
||||||
loaded = true;
|
loaded = true;
|
||||||
|
@ -16,7 +16,7 @@ import java.io.Serializable;
|
|||||||
* maps, and the like.
|
* maps, and the like.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class ByteArray implements Serializable, Comparable {
|
public class ByteArray implements Serializable, Comparable<ByteArray> {
|
||||||
private byte[] _data;
|
private byte[] _data;
|
||||||
private int _valid;
|
private int _valid;
|
||||||
private int _offset;
|
private int _offset;
|
||||||
@ -85,9 +85,8 @@ public class ByteArray implements Serializable, Comparable {
|
|||||||
return (llen == rlen) && DataHelper.eq(lhs, loff, rhs, roff, llen);
|
return (llen == rlen) && DataHelper.eq(lhs, loff, rhs, roff, llen);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final int compareTo(Object obj) {
|
public final int compareTo(ByteArray ba) {
|
||||||
if (obj.getClass() != getClass()) throw new ClassCastException("invalid object: " + obj);
|
return DataHelper.compareTo(_data, ba.getData());
|
||||||
return DataHelper.compareTo(_data, ((ByteArray)obj).getData());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -300,9 +300,9 @@ public class FileUtil {
|
|||||||
if (!_failedOracle) {
|
if (!_failedOracle) {
|
||||||
try {
|
try {
|
||||||
Class<?> p200 = Class.forName("java.util.jar.Pack200", true, ClassLoader.getSystemClassLoader());
|
Class<?> p200 = Class.forName("java.util.jar.Pack200", true, ClassLoader.getSystemClassLoader());
|
||||||
Method newUnpacker = p200.getMethod("newUnpacker", (Class[]) null);
|
Method newUnpacker = p200.getMethod("newUnpacker");
|
||||||
Object unpacker = newUnpacker.invoke(null,(Object[]) null);
|
Object unpacker = newUnpacker.invoke(null,(Object[]) null);
|
||||||
Method unpack = unpacker.getClass().getMethod("unpack", new Class[] {InputStream.class, JarOutputStream.class});
|
Method unpack = unpacker.getClass().getMethod("unpack", InputStream.class, JarOutputStream.class);
|
||||||
// throws IOException
|
// throws IOException
|
||||||
unpack.invoke(unpacker, new Object[] {in, out});
|
unpack.invoke(unpacker, new Object[] {in, out});
|
||||||
return;
|
return;
|
||||||
@ -321,9 +321,9 @@ public class FileUtil {
|
|||||||
if (!_failedApache) {
|
if (!_failedApache) {
|
||||||
try {
|
try {
|
||||||
Class<?> p200 = Class.forName("org.apache.harmony.unpack200.Archive", true, ClassLoader.getSystemClassLoader());
|
Class<?> p200 = Class.forName("org.apache.harmony.unpack200.Archive", true, ClassLoader.getSystemClassLoader());
|
||||||
Constructor<?> newUnpacker = p200.getConstructor(new Class[] {InputStream.class, JarOutputStream.class});
|
Constructor<?> newUnpacker = p200.getConstructor(InputStream.class, JarOutputStream.class);
|
||||||
Object unpacker = newUnpacker.newInstance(new Object[] {in, out});
|
Object unpacker = newUnpacker.newInstance(in, out);
|
||||||
Method unpack = unpacker.getClass().getMethod("unpack", (Class[]) null);
|
Method unpack = unpacker.getClass().getMethod("unpack");
|
||||||
// throws IOException or Pack200Exception
|
// throws IOException or Pack200Exception
|
||||||
unpack.invoke(unpacker, (Object[]) null);
|
unpack.invoke(unpacker, (Object[]) null);
|
||||||
return;
|
return;
|
||||||
|
Reference in New Issue
Block a user