jerryhui633 / google-gson

Automatically exported from code.google.com/p/google-gson
0 stars 0 forks source link

NPE calling toJson() with a null UUID field #369

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
public class TestToJsonObject
{
  private UUID u1 = null;

  public TestToJsonObject() {}
}

Gson gson = new GsonBuilder().create();
TestToJsonObject o = new TestToJsonObject();
System.out.println(gson.toJson(o));

What is the expected output? What do you see instead?
I would expect to see no output. Instead I get the following NPE:
java.lang.NullPointerException
    at com.google.gson.internal.bind.TypeAdapters$17.write(TypeAdapters.java:411)
    at com.google.gson.internal.bind.TypeAdapters$17.write(TypeAdapters.java:400)
    at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRuntimeTypeWrapper.java:66)
    at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.write(ReflectiveTypeAdapterFactory.java:82)
    at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.write(ReflectiveTypeAdapterFactory.java:194)
    at com.google.gson.Gson.toJson(Gson.java:510)
    at com.google.gson.Gson.toJson(Gson.java:489)
    at com.google.gson.Gson.toJson(Gson.java:444)
    at com.google.gson.Gson.toJson(Gson.java:424)

What version of the product are you using? On what operating system?
r992

Please provide any additional information below.

Original issue reported on code.google.com by chris.p....@gmail.com on 13 Oct 2011 at 5:59

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r993.

Original comment by limpbizkit on 14 Oct 2011 at 3:17

GoogleCodeExporter commented 9 years ago
Thanks for the perfect bug report. Fixed!

Original comment by limpbizkit on 14 Oct 2011 at 3:17