I have the following code:
final JsonObject source = source.toJson();
final JsonElement relatedSpace = source.get("myField");
if(relatedSpace.isJsonObject()){
  //do something
}
isJsonObject() does return instanceof JsonObject; according the the Gson code. instanceof should do a null check first, so I'm not sure how it's possible that my code is throwing a NullPointerException when relatedSpace is null. I can easily check for null first to fix the issue, but I'm wondering why this happens.
 
     
     
    