I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit 97a9a609 authored by str4d's avatar str4d
Browse files

Use copy constructor instead of clone()

parent 8b8e2c88
No related branches found
No related tags found
No related merge requests found
...@@ -151,7 +151,7 @@ public class OutNetMessage implements CDPQEntry { ...@@ -151,7 +151,7 @@ public class OutNetMessage implements CDPQEntry {
if (_log.shouldLog(Log.INFO)) { if (_log.shouldLog(Log.INFO)) {
synchronized (this) { synchronized (this) {
locked_initTimestamps(); locked_initTimestamps();
return (Map<String, Long>)_timestamps.clone(); return new HashMap<String, Long>(_timestamps);
} }
} }
return Collections.emptyMap(); return Collections.emptyMap();
......
...@@ -44,12 +44,12 @@ class SearchState { ...@@ -44,12 +44,12 @@ class SearchState {
public Hash getTarget() { return _searchKey; } public Hash getTarget() { return _searchKey; }
public Set<Hash> getPending() { public Set<Hash> getPending() {
synchronized (_pendingPeers) { synchronized (_pendingPeers) {
return (Set<Hash>)_pendingPeers.clone(); return new HashSet<Hash>(_pendingPeers);
} }
} }
public Set<Hash> getAttempted() { public Set<Hash> getAttempted() {
synchronized (_attemptedPeers) { synchronized (_attemptedPeers) {
return (Set<Hash>)_attemptedPeers.clone(); return new HashSet<Hash>(_attemptedPeers);
} }
} }
public Set<Hash> getClosestAttempted(int max) { public Set<Hash> getClosestAttempted(int max) {
...@@ -78,12 +78,12 @@ class SearchState { ...@@ -78,12 +78,12 @@ class SearchState {
} }
public Set<Hash> getSuccessful() { public Set<Hash> getSuccessful() {
synchronized (_successfulPeers) { synchronized (_successfulPeers) {
return (Set<Hash>)_successfulPeers.clone(); return new HashSet<Hash>(_successfulPeers);
} }
} }
public Set<Hash> getFailed() { public Set<Hash> getFailed() {
synchronized (_failedPeers) { synchronized (_failedPeers) {
return (Set<Hash>)_failedPeers.clone(); return new HashSet<Hash>(_failedPeers);
} }
} }
public boolean completed() { return _completed != -1; } public boolean completed() { return _completed != -1; }
...@@ -155,7 +155,7 @@ class SearchState { ...@@ -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) { public void replyTimeout(Hash peer) {
synchronized (_pendingPeers) { synchronized (_pendingPeers) {
......
...@@ -58,17 +58,17 @@ class StoreState { ...@@ -58,17 +58,17 @@ class StoreState {
public DatabaseEntry getData() { return _data; } public DatabaseEntry getData() { return _data; }
public Set<Hash> getPending() { public Set<Hash> getPending() {
synchronized (_pendingPeers) { synchronized (_pendingPeers) {
return (Set<Hash>)_pendingPeers.clone(); return new HashSet<Hash>(_pendingPeers);
} }
} }
public Set<Hash> getAttempted() { public Set<Hash> getAttempted() {
synchronized (_attemptedPeers) { synchronized (_attemptedPeers) {
return (Set<Hash>)_attemptedPeers.clone(); return new HashSet<Hash>(_attemptedPeers);
} }
} }
public Set<Hash> getSuccessful() { public Set<Hash> getSuccessful() {
synchronized (_successfulPeers) { synchronized (_successfulPeers) {
return (Set<Hash>)_successfulPeers.clone(); return new HashSet<Hash>(_successfulPeers);
} }
} }
/** unused */ /** unused */
...@@ -82,7 +82,7 @@ class StoreState { ...@@ -82,7 +82,7 @@ class StoreState {
public Set<Hash> getFailed() { public Set<Hash> getFailed() {
synchronized (_failedPeers) { synchronized (_failedPeers) {
return (Set<Hash>)_failedPeers.clone(); return new HashSet<Hash>(_failedPeers);
} }
} }
public boolean completed() { return _completed != -1; } public boolean completed() { return _completed != -1; }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment