forked from I2P_Developers/i2p.i2p
Findbugs in imported core code
This commit is contained in:
@@ -212,7 +212,6 @@ public class HashCash implements Comparable<HashCash> {
|
|||||||
/**
|
/**
|
||||||
* Two objects are considered equal if they are both of type HashCash and have an identical string representation
|
* Two objects are considered equal if they are both of type HashCash and have an identical string representation
|
||||||
*/
|
*/
|
||||||
/* FIXME missing hashCode() method FIXME */
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if(obj instanceof HashCash)
|
if(obj instanceof HashCash)
|
||||||
@@ -220,6 +219,14 @@ public class HashCash implements Comparable<HashCash> {
|
|||||||
else
|
else
|
||||||
return super.equals(obj);
|
return super.equals(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implemented based on definition of equals()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return ("HashCash:"+toString()).hashCode();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the canonical string representation of the HashCash
|
* Returns the canonical string representation of the HashCash
|
||||||
@@ -330,14 +337,15 @@ private static long bytesToLong(byte[] b) {
|
|||||||
List<String> tempList;
|
List<String> tempList;
|
||||||
boolean first = true;
|
boolean first = true;
|
||||||
|
|
||||||
for(String key: extensions.keySet()) {
|
for(Map.Entry<String, List<String>> entry: extensions.entrySet()) {
|
||||||
|
String key = entry.getKey();
|
||||||
if(key.contains(":") || key.contains(";") || key.contains("="))
|
if(key.contains(":") || key.contains(";") || key.contains("="))
|
||||||
throw new IllegalArgumentException("Extension key contains an illegal character. " + key);
|
throw new IllegalArgumentException("Extension key contains an illegal character. " + key);
|
||||||
if(!first)
|
if(!first)
|
||||||
result.append(";");
|
result.append(";");
|
||||||
first = false;
|
first = false;
|
||||||
result.append(key);
|
result.append(key);
|
||||||
tempList = extensions.get(key);
|
tempList = entry.getValue();
|
||||||
|
|
||||||
if(null != tempList) {
|
if(null != tempList) {
|
||||||
result.append("=");
|
result.append("=");
|
||||||
@@ -442,7 +450,7 @@ private static long bytesToLong(byte[] b) {
|
|||||||
public static int estimateValue(int secs) throws NoSuchAlgorithmException {
|
public static int estimateValue(int secs) throws NoSuchAlgorithmException {
|
||||||
initEstimates();
|
initEstimates();
|
||||||
int result = 0;
|
int result = 0;
|
||||||
long millis = secs * 1000 * 65536;
|
long millis = secs * 1000L * 65536;
|
||||||
millis /= milliFor16;
|
millis /= milliFor16;
|
||||||
|
|
||||||
while(millis > 1) {
|
while(millis > 1) {
|
||||||
|
@@ -95,7 +95,7 @@ public class Sha256Standalone extends BaseHashStandalone {
|
|||||||
private static final int[] w = new int[64];
|
private static final int[] w = new int[64];
|
||||||
|
|
||||||
/** caches the result of the correctness test, once executed. */
|
/** caches the result of the correctness test, once executed. */
|
||||||
private static Boolean valid;
|
private static volatile Boolean valid;
|
||||||
|
|
||||||
/** 256-bit interim result. */
|
/** 256-bit interim result. */
|
||||||
private int h0, h1, h2, h3, h4, h5, h6, h7;
|
private int h0, h1, h2, h3, h4, h5, h6, h7;
|
||||||
@@ -218,7 +218,7 @@ public class Sha256Standalone extends BaseHashStandalone {
|
|||||||
md.update((byte) 0x62); // b
|
md.update((byte) 0x62); // b
|
||||||
md.update((byte) 0x63); // c
|
md.update((byte) 0x63); // c
|
||||||
String result = "broken"; //Util.toString(md.digest());
|
String result = "broken"; //Util.toString(md.digest());
|
||||||
valid = new Boolean(DIGEST0.equals(result));
|
valid = Boolean.valueOf(DIGEST0.equals(result));
|
||||||
}
|
}
|
||||||
|
|
||||||
return valid.booleanValue();
|
return valid.booleanValue();
|
||||||
|
Reference in New Issue
Block a user