Skip to content

Commit

Permalink
Fix NPE when retrieving an entity with a null UUID
Browse files Browse the repository at this point in the history
While the null UUID is almost certainly an error, the old
implementation did not NPE as it used a plain HashMap for lookup
by UUID, whereas we use a ConcurrentHashMap which will NPE on
null keys.
  • Loading branch information
Spottedleaf committed Jun 24, 2024
1 parent 4c36d6d commit 641694d
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,15 @@ public Entity get(final int id) {

@Override
public Entity get(final UUID id) {
return maskNonAccessible(this.entityByUUID.get(id));
return maskNonAccessible(id == null ? null : this.entityByUUID.get(id));
}

public boolean hasEntity(final UUID uuid) {
return this.get(uuid) != null;
}

public String getDebugInfo() {
return "count_id:" + this.entityById.size() + ",count_uuid:" + this.entityByUUID.size() + ",region_count:" + this.regions.size();
return "count_id:" + this.entityById.size() + ",count_uuid:" + this.entityByUUID.size() + ",count_accessible:" + this.getEntityCount() + ",region_count:" + this.regions.size();
}

protected static final class ArrayIterable<T> implements Iterable<T> {
Expand Down

0 comments on commit 641694d

Please sign in to comment.