If a player summons/spawn with a mob egg a hostile entity (Creepers, Spiders, Zombies, Slimes, LavaSlimes etc.), and then changes his gamemode to spectator mode, the hostile entities will despawn. And also, if the player is on spectator mode, and summons a hostile entity with /summon, the mob will be shown for one tick (Or two? I don't know, I just know it's a very short time, maybe for one frame or two), and then will despawn. Then, if the player goes back to survival, adventure or creative mode, he will be able to spawn the hostile entities again.
Works as intended. See MC-46776