[SPIGOT-6302] Can spawnEntity() return a null? JavaDoc vs @NotNull Created: 01/Jan/21 Updated: 01/Jan/21 |
|
Status: | Open |
Project: | Spigot |
Component/s: | None |
Affects Version/s: | None |
Fix Version/s: | None |
Type: | Bug | Priority: | Minor |
Reporter: | tastybento | Assignee: | Unassigned |
Resolution: | Unresolved | Votes: | 0 |
Labels: | None |
Version: | This server is running CraftBukkit version git-Spigot-ff439d1-560b65c (MC: 1.16.4) (Implementing API version 1.16.4-R0.1-SNAPSHOT) |
Guidelines Read: | Yes |
Description |
It's not clear whether spawnEntity can generate a null because the notation is @NotNull but the JavaDoc says that it will be null if it was unsuccessful:
/** * Creates a entity at the given {@link Location} * * @param loc The location to spawn the entity * @param type The entity to spawn * @return Resulting Entity of this method, or null if it was unsuccessful */ @NotNull public Entity spawnEntity(@NotNull Location loc, @NotNull EntityType type);
I do null checks on this call, but static code analysis caught this and said it wasn't required. See:
|
Comments |
Comment by md_5 [ 01/Jan/21 ] |
The current implementation can't return null, but I'm wondering if Nullable on the API would not be more correct (eg event cancels the spawn). Probably returning null at this point would just break things though. |