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

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

Comments

@spring-projects-issues
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 MongoTemplate.java 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 au.org.aurin.workflow.datamodel.ComponentType
	at com.mongodb.util.JSON.serialize(JSON.java:261)
	at com.mongodb.util.JSON.serialize(JSON.java:141)
	at com.mongodb.util.JSON.serialize(JSON.java:58)
	at com.mongodb.BasicDBObject.toString(BasicDBObject.java:84)
	at java.lang.String.valueOf(String.java:2902)
	at java.lang.StringBuilder.append(StringBuilder.java:128)
	at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1241)
	at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1233)
	at org.springframework.data.mongodb.core.MongoTemplate.find(MongoTemplate.java:471)
	at org.springframework.data.mongodb.core.MongoTemplate.find(MongoTemplate.java:466)
	at au.org.aurin.workflow.persistence.ComponentRepository.getByType(ComponentRepository.java:42)

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
Labels
in: core type: bug
Projects
None yet
Development

No branches or pull requests

2 participants