Skip to content

Commit

Permalink
Prevent concurrent modification exception.
Browse files Browse the repository at this point in the history
  • Loading branch information
mnlipp committed Jan 31, 2025
1 parent 4fc0d6f commit 6a1273e
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,16 +140,20 @@ public Set<String> vms() {
* @return the string
*/
@Override
@SuppressWarnings("PMD.AvoidLiteralsInIfCondition")
@SuppressWarnings({ "PMD.AvoidLiteralsInIfCondition",
"PMD.AvoidSynchronizedStatement" })
public String toString() {
StringBuilder builder = new StringBuilder(50);
builder.append("VmPool [name=").append(name).append(", permissions=")
.append(permissions).append(", vms=");
if (vms.size() <= 3) {
builder.append(vms);
} else {
builder.append('[').append(vms.stream().limit(3).map(s -> s + ",")
.collect(Collectors.joining())).append("...]");
synchronized (vms) {
builder.append('[').append(vms.stream().limit(3)
.map(s -> s + ",").collect(Collectors.joining()))
.append("...]");
}
}
builder.append(']');
return builder.toString();
Expand Down

0 comments on commit 6a1273e

Please sign in to comment.