Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON can't serialize Enum when printing Query in DEBUG message [DATAMONGO-495] #1429

spring-projects-issues opened this issue Jul 25, 2012 · 0 comments
in: core type: bug


Copy link

@spring-projects-issues spring-projects-issues commented Jul 25, 2012

William Voorsluys opened DATAMONGO-495 and commented

I'm trying to execute the following code to query MongoDB where the field 'type' is an Enum.

this.getOperations().find(new Query(Criteria.where("type").is(type)), ComponentDefinition.class);

I get an error saying the class can't be serialized (see exception below).

But I noticed the error only happens when the log level is set to DEBUG, when a line in attempts to add the Query to a debug message. The serialization error is then triggered by toString() of BasicDBObject. The exception thrown is:

java.lang.RuntimeException: json can't serialize type : class
	at com.mongodb.util.JSON.serialize(
	at com.mongodb.util.JSON.serialize(
	at com.mongodb.util.JSON.serialize(
	at com.mongodb.BasicDBObject.toString(
	at java.lang.String.valueOf(
	at java.lang.StringBuilder.append(

When log level is set to INFO, the problem doesn't appear. The enum value is serialized as expected in all DB operations.

Affects: 1.0.3, 1.1 M2

Referenced from: commits 594ddbd, 04a17ca

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
in: core type: bug
None yet

No branches or pull requests

2 participants