Use copy constructor instead of clone()

This commit is contained in:
str4d
2013-11-27 01:55:29 +00:00
parent 8b8e2c88c1
commit 97a9a6090a
3 changed files with 10 additions and 10 deletions

View File

@ -151,7 +151,7 @@ public class OutNetMessage implements CDPQEntry {
if (_log.shouldLog(Log.INFO)) {
synchronized (this) {
locked_initTimestamps();
return (Map<String, Long>)_timestamps.clone();
return new HashMap<String, Long>(_timestamps);
}
}
return Collections.emptyMap();

View File

@ -44,12 +44,12 @@ class SearchState {
public Hash getTarget() { return _searchKey; }
public Set<Hash> getPending() {
synchronized (_pendingPeers) {
return (Set<Hash>)_pendingPeers.clone();
return new HashSet<Hash>(_pendingPeers);
}
}
public Set<Hash> getAttempted() {
synchronized (_attemptedPeers) {
return (Set<Hash>)_attemptedPeers.clone();
return new HashSet<Hash>(_attemptedPeers);
}
}
public Set<Hash> getClosestAttempted(int max) {
@ -78,12 +78,12 @@ class SearchState {
}
public Set<Hash> getSuccessful() {
synchronized (_successfulPeers) {
return (Set<Hash>)_successfulPeers.clone();
return new HashSet<Hash>(_successfulPeers);
}
}
public Set<Hash> getFailed() {
synchronized (_failedPeers) {
return (Set<Hash>)_failedPeers.clone();
return new HashSet<Hash>(_failedPeers);
}
}
public boolean completed() { return _completed != -1; }
@ -155,7 +155,7 @@ class SearchState {
}
}
public Set<Hash> getRepliedPeers() { synchronized (_repliedPeers) { return (Set<Hash>)_repliedPeers.clone(); } }
public Set<Hash> getRepliedPeers() { synchronized (_repliedPeers) { return new HashSet<Hash>(_repliedPeers); } }
public void replyTimeout(Hash peer) {
synchronized (_pendingPeers) {

View File

@ -58,17 +58,17 @@ class StoreState {
public DatabaseEntry getData() { return _data; }
public Set<Hash> getPending() {
synchronized (_pendingPeers) {
return (Set<Hash>)_pendingPeers.clone();
return new HashSet<Hash>(_pendingPeers);
}
}
public Set<Hash> getAttempted() {
synchronized (_attemptedPeers) {
return (Set<Hash>)_attemptedPeers.clone();
return new HashSet<Hash>(_attemptedPeers);
}
}
public Set<Hash> getSuccessful() {
synchronized (_successfulPeers) {
return (Set<Hash>)_successfulPeers.clone();
return new HashSet<Hash>(_successfulPeers);
}
}
/** unused */
@ -82,7 +82,7 @@ class StoreState {
public Set<Hash> getFailed() {
synchronized (_failedPeers) {
return (Set<Hash>)_failedPeers.clone();
return new HashSet<Hash>(_failedPeers);
}
}
public boolean completed() { return _completed != -1; }