Can spawnEntity() return a null? JavaDoc vs @NotNull

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Minor
    • None
    • Affects Version/s: None
    • None
    • This server is running CraftBukkit version git-Spigot-ff439d1-560b65c (MC: 1.16.4) (Implementing API version 1.16.4-R0.1-SNAPSHOT)
    • Yes

      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:

      https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/browse/src/main/java/org/bukkit/World.java#531

       

            Assignee:
            Unassigned
            Reporter:
            tastybento
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: