{"action":"created","issue":{"url":"https://api.github.com/repos/lviggiano/owner/issues/200","repository_url":"https://api.github.com/repos/lviggiano/owner","labels_url":"https://api.github.com/repos/lviggiano/owner/issues/200/labels{/name}","comments_url":"https://api.github.com/repos/lviggiano/owner/issues/200/comments","events_url":"https://api.github.com/repos/lviggiano/owner/issues/200/events","html_url":"https://github.com/lviggiano/owner/issues/200","id":217799873,"number":200,"title":"UnsupportedOperationException when auto-converting business object using String constructor","user":{"login":"fstuff","id":1115274,"avatar_url":"https://avatars0.githubusercontent.com/u/1115274?v=3","gravatar_id":"","url":"https://api.github.com/users/fstuff","html_url":"https://github.com/fstuff","followers_url":"https://api.github.com/users/fstuff/followers","following_url":"https://api.github.com/users/fstuff/following{/other_user}","gists_url":"https://api.github.com/users/fstuff/gists{/gist_id}","starred_url":"https://api.github.com/users/fstuff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fstuff/subscriptions","organizations_url":"https://api.github.com/users/fstuff/orgs","repos_url":"https://api.github.com/users/fstuff/repos","events_url":"https://api.github.com/users/fstuff/events{/privacy}","received_events_url":"https://api.github.com/users/fstuff/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-03-29T08:23:46Z","updated_at":"2017-03-29T08:51:11Z","closed_at":null,"body":"This page of the Owner documentation http://owner.aeonbits.org/docs/type-conversion/ states that\r\n\r\n> OWNER API supports automatic conversion for: [snip] 7. Any instantiable class declaring a public constructor with a single argument of type java.lang.String.\r\n\r\nI have declared a constructor in my class to take a single String argument:\r\n\r\n```\r\npublic TreePair(java.lang.String arg)\r\n{\r\n\tString split[] = arg.split(\":\");\r\n\t\t\r\n\tResourceTree firstTree = KitchenSyncApp.getInstance().getResourceTree(UUID.fromString(split[0]));\r\n\tResourceTree secondTree = KitchenSyncApp.getInstance().getResourceTree(UUID.fromString(split[1]));\r\n\t\t\r\n\tthis.lesserUUIDTree = TreePair.selectTreeByLowestUUID(firstTree, secondTree);\r\n\tthis.greaterUUIDTree = (this.lesserUUIDTree.equals(firstTree) ? secondTree : firstTree);\r\n}\r\n```\r\n\r\nMy config source file has the following line:\r\n```\r\n@Key(\"sync.app.treePairs\")\r\n@DefaultValue(\"7275d9a3-66f5-45f9-8930-614a54af4b3c:1f033151-49a0-4484-8358-3022fb6c40d5\")\r\nSet<TreePair> treePairs();\r\n```\r\n\r\nWhen I run my program, I get the following UnsupportedOperationException stack trace:\r\n\r\n> Exception in thread \"main\" java.lang.ExceptionInInitializerError\r\n> Caused by: java.lang.UnsupportedOperationException: Cannot convert '7275d9a3-66f5-45f9-8930-614a54af4b3c:1f033151-49a0-4484-8358-3022fb6c40d5' to kitchensync.resource.tree.TreePair\r\n> \tat org.aeonbits.owner.Util.unsupported(Util.java:132)\r\n> \tat org.aeonbits.owner.Converters.unsupportedConversion(Converters.java:280)\r\n> \tat org.aeonbits.owner.Converters.access$300(Converters.java:42)\r\n> \tat org.aeonbits.owner.Converters$11.tryConvert(Converters.java:256)\r\n> \tat org.aeonbits.owner.Converters.doConvert(Converters.java:268)\r\n> \tat org.aeonbits.owner.Converters.access$100(Converters.java:42)\r\n> \tat org.aeonbits.owner.Converters$1.tryConvert(Converters.java:57)\r\n> \tat org.aeonbits.owner.Converters$2.convertToArray(Converters.java:85)\r\n> \tat org.aeonbits.owner.Converters$2.tryConvert(Converters.java:75)\r\n> \tat org.aeonbits.owner.Converters.doConvert(Converters.java:268)\r\n> \tat org.aeonbits.owner.Converters.convert(Converters.java:263)\r\n> \tat org.aeonbits.owner.PropertiesInvocationHandler.resolveProperty(PropertiesInvocationHandler.java:87)\r\n> \tat org.aeonbits.owner.PropertiesInvocationHandler.invoke(PropertiesInvocationHandler.java:67)\r\n> \tat com.sun.proxy.$Proxy5.treePairs(Unknown Source)\r\n> \tat kitchensync.KitchenSyncApp.<init>(KitchenSyncApp.java:85)\r\n> \tat kitchensync.KitchenSyncApp.<clinit>(KitchenSyncApp.java:35)\r\n> \r\n\r\nI was able to use the @ConverterClass annotation to specify a converter class, and that seemed to work to load my Set of TreePair business objects.  I thought based on the documentation that I could simplify my code by eliminating the converter class and just implementing my simple conversion logic in the business object's constructor.  Based on my reading of the documentation this should not be happening.  I would appreciate any comments or suggestions.  Am I missing something?"},"comment":{"url":"https://api.github.com/repos/lviggiano/owner/issues/comments/290025708","html_url":"https://github.com/lviggiano/owner/issues/200#issuecomment-290025708","issue_url":"https://api.github.com/repos/lviggiano/owner/issues/200","id":290025708,"user":{"login":"fstuff","id":1115274,"avatar_url":"https://avatars0.githubusercontent.com/u/1115274?v=3","gravatar_id":"","url":"https://api.github.com/users/fstuff","html_url":"https://github.com/fstuff","followers_url":"https://api.github.com/users/fstuff/followers","following_url":"https://api.github.com/users/fstuff/following{/other_user}","gists_url":"https://api.github.com/users/fstuff/gists{/gist_id}","starred_url":"https://api.github.com/users/fstuff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fstuff/subscriptions","organizations_url":"https://api.github.com/users/fstuff/orgs","repos_url":"https://api.github.com/users/fstuff/repos","events_url":"https://api.github.com/users/fstuff/events{/privacy}","received_events_url":"https://api.github.com/users/fstuff/received_events","type":"User","site_admin":false},"created_at":"2017-03-29T08:51:11Z","updated_at":"2017-03-29T08:51:11Z","body":"It looks like this is actually happening because my constructor is causing an exception to be thrown.  This block of code in Converters.java seems to catch any underlying errors and simply proceed:\r\n\r\n```\r\n    CLASS_WITH_STRING_CONSTRUCTOR {\r\n        @Override\r\n        Object tryConvert(Method targetMethod, Class<?> targetType, String text) {\r\n            try {\r\n                Constructor<?> constructor = targetType.getConstructor(String.class);\r\n                return constructor.newInstance(text);\r\n            } catch (Exception e) {\r\n                return SKIP;\r\n            }\r\n        }\r\n    },\r\n```\r\n\r\nOther enums in the Converters class throw a different exception rather than skipping if they catch an exception.  I think the behavior should probably be carried over to here."}}
{"actor":{"display_login":"fstuff"}}