getSchema() of java.util.Properties fails
GoogleCodeExporter opened this issue · comments
Google Code Exporter commented
What steps will reproduce the problem?
1. Try to get the schema of java.util.Properties like in the attached testcase
What is the expected output? What do you see instead?
I succefully get the schema
What version of the product are you using? On what operating system?
Tried with protostuff 1.0.7 and current trunk.
Please provide any additional information below.
Exception in thread "main" java.lang.IllegalArgumentException: No enum constant
com.dyuproject.protostuff.MapSchema.MessageFactories.Properties
at java.lang.Enum.valueOf(Enum.java:236)
at
com.dyuproject.protostuff.MapSchema$MessageFactories.valueOf(MapSchema.java:54)
at
com.dyuproject.protostuff.runtime.DefaultIdStrategy.getMapFactory(DefaultIdStrat
egy.java:261)
at
com.dyuproject.protostuff.runtime.RuntimeMapFieldFactory$17.create(RuntimeMapFie
ldFactory.java:1702)
at
com.dyuproject.protostuff.runtime.RuntimeSchema.createFrom(RuntimeSchema.java:23
6)
at
com.dyuproject.protostuff.runtime.RuntimeSchema.createFrom(RuntimeSchema.java:15
6)
at com.dyuproject.protostuff.runtime.IdStrategy.newSchema(IdStrategy.java:129)
at
com.dyuproject.protostuff.runtime.DefaultIdStrategy$Lazy.getSchema(DefaultIdStra
tegy.java:630)
at
com.dyuproject.protostuff.runtime.RuntimeSchema.getSchema(RuntimeSchema.java:119
)
at
com.dyuproject.protostuff.runtime.RuntimeSchema.getSchema(RuntimeSchema.java:111
)
at testcase.TestCase.main(TestCase.java:14)
I'm not sure if I do something wrong or if this is a bug.
Cheers,
David
Original issue reported on code.google.com by w...@munzinger.de
on 12 Nov 2013 at 9:01
Attachments:
Google Code Exporter commented
Top level messages usually need to be pojos.
The workaround for that is to register a custom schema and delegate.
I've attached the files which you can use in your project (includes the
testcase)
That is the recommended way when working with non-pojos.
In this case, since Properties is like a Map<String,String>, it is treated like
a message.
For scalar types, only a custom delegate is needed.
Original comment by david.yu...@gmail.com
on 12 Nov 2013 at 10:24
Attachments:
Google Code Exporter commented
Thank you very much for your helpful response!
Your solution works great except it doesn't preserve "default" values, but we
can live without them.
Original comment by weber.au...@gmail.com
on 20 Nov 2013 at 10:55