Findbugs in imported core code

This commit is contained in:
str4d
2013-11-20 09:15:12 +00:00
parent 796dbc5d2e
commit a7a7e96188
2 changed files with 14 additions and 6 deletions

View File

@@ -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
*/
/* FIXME missing hashCode() method FIXME */
@Override
public boolean equals(Object obj) {
if(obj instanceof HashCash)
@@ -220,6 +219,14 @@ public class HashCash implements Comparable<HashCash> {
else
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
@@ -330,14 +337,15 @@ private static long bytesToLong(byte[] b) {
List<String> tempList;
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("="))
throw new IllegalArgumentException("Extension key contains an illegal character. " + key);
if(!first)
result.append(";");
first = false;
result.append(key);
tempList = extensions.get(key);
tempList = entry.getValue();
if(null != tempList) {
result.append("=");
@@ -442,7 +450,7 @@ private static long bytesToLong(byte[] b) {
public static int estimateValue(int secs) throws NoSuchAlgorithmException {
initEstimates();
int result = 0;
long millis = secs * 1000 * 65536;
long millis = secs * 1000L * 65536;
millis /= milliFor16;
while(millis > 1) {