mirror of
https://github.com/ChronosX88/KademliaDHT.git
synced 2024-11-24 19:22:18 +00:00
Updated the routing table bucket class to copy the contacts to another data structure before sending them, preventing other parts of the system from modifying the core data structure
This commit is contained in:
parent
807a9965d0
commit
a9e5402697
@ -194,7 +194,21 @@ public class KadBucketImpl implements KadBucket
|
||||
@Override
|
||||
public synchronized List<Contact> getContacts()
|
||||
{
|
||||
return (this.contacts.isEmpty()) ? new ArrayList<>() : new ArrayList<>(this.contacts);
|
||||
final ArrayList<Contact> ret = new ArrayList<>();
|
||||
|
||||
/* If we have no contacts, return the blank arraylist */
|
||||
if (this.contacts.isEmpty())
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* We have contacts, lets copy put them into the arraylist and return */
|
||||
for (Contact c : this.contacts)
|
||||
{
|
||||
ret.add(c);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user