Re: Issue 165 in google-gson: Enum constant does not exist

5 views
Skip to first unread message

googl...@googlecode.com

unread,
Aug 21, 2010, 4:33:00 PM8/21/10
to google-gson...@googlegroups.com

Comment #2 on issue 165 by joel.leitch: Enum constant does not exist
http://code.google.com/p/google-gson/issues/detail?id=165

Sorry for jumping in a bit late here. What version of Gson are you running
that requires you to register both a custom deserializer and an instance
creator. I know we had that bug a while back, but I thought it was fixed
in version 1.3 and later.

Is it possible to use the Gson versioning to protect you from the
sender/receiver incompatibilities? The common approach for API versioning
is that the client will request the API version it would like to use with
the server. The server is then able to process and respond to the client
without breaking backward compatibility. As new features get added to API
calls (or new API calls emerge) then the server should support a new
version.

googl...@googlecode.com

unread,
Nov 2, 2010, 9:48:44 PM11/2/10
to google-gson...@googlegroups.com
Updates:
Labels: Milestone-Undefined

Comment #3 on issue 165 by inder123: Enum constant does not exist
http://code.google.com/p/google-gson/issues/detail?id=165

(No comment was entered for this change.)

googl...@googlecode.com

unread,
Mar 22, 2011, 6:16:01 AM3/22/11
to google-gson...@googlegroups.com
Updates:
Status: Invalid

Comment #4 on issue 165 by joel.leitch: Enum constant does not exist
http://code.google.com/p/google-gson/issues/detail?id=165

I do not consider this a Gson issue, but rather a versioning issue between
the client and server.

googl...@googlecode.com

unread,
Jun 5, 2015, 6:17:37 PM6/5/15
to google-gson...@googlegroups.com

Comment #5 on issue 165 by stu26c...@gmail.com: Enum constant does not exist
https://code.google.com/p/google-gson/issues/detail?id=165

I actually ran into the opposite outcome - I was deserializing a JSON
object into a class that contained an enum member:

Class C {
public Enum E {
V1, V2
}
private E e;
}

Due to legacy interfaces, it had a setE( String method ):

Class C {
public Enum E {
V1, V2
}
private E e;

public setE( string e ) {
this.e = Enum.valueOf(e)
}
}

I was expecting Gson to throw up the IllegalArgumentException from valueOf.

Instead it silently swallowed it, and set e to null.

So what was requested above and marked as invalid (and I agree it should be
invalid) ... is actually how it seems to work now :/






--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings
Reply all
Reply to author
Forward
0 new messages