ahgittin commented on pull request #1267:
URL: https://github.com/apache/brooklyn-server/pull/1267#issuecomment-956182620


   So, changing `params` to be the more general `Object` doesn't allow some of 
the historic xml deserialization.
   
   A better fix is to annotate `ConfigBag` so that Jackson JSON/YAML can work 
with it more nicely.  This on that class should do it:
   
   ```
   @JsonAutoDetect(fieldVisibility = Visibility.ANY, isGetterVisibility = 
Visibility.NONE, getterVisibility = Visibility.NONE, setterVisibility = 
Visibility.NONE)
   ```
   
   (Revert the change of `params`, back to being a `ConfigBag`.)
   
   The test you added to `BRTJST` passes with the above annotation.
   
   I tried the following test also in `BRTJST` which also passes and is 
probably worth including here (in addition to the test you have here):
   
   ```
       @Test
       public void testConfigBagSerialization() throws Exception {
           ConfigBag bag = ConfigBag.newInstance();
           bag.put(ConfigKeys.newConfigKey(String.class, "stringTypedKey"), 
"foo");
           bag.putStringKey("stringUntypedKey", "bar");
           bag.putStringKey("intUntypedKey", 2);
           bag.getStringKey("stringUntypedKey");
   
           String out = ser(bag);
           Assert.assertEquals(out, 
"{\"type\":\"org.apache.brooklyn.util.core.config.ConfigBag\",\"config\":{\"stringTypedKey\":\"foo\",\"stringUntypedKey\":\"bar\",\"intUntypedKey\":2},\"unusedConfig\":{\"stringTypedKey\":\"foo\",\"intUntypedKey\":2},\"live\":false,\"sealed\":false}");
   
           ConfigBag in = (ConfigBag) deser(out);
           // used and unused is serialized
           Asserts.assertSize(in.getUnusedConfig(), 2);
           Asserts.assertEquals(in.getAllConfig(), bag.getAllConfig());
       }
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@brooklyn.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to