[jira] [Commented] (IGNITE-9043) Collections cannot be assigned to fields of type Object in BinaryObject
[ https://issues.apache.org/jira/browse/IGNITE-9043?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16568353#comment-16568353 ] ASF GitHub Bot commented on IGNITE-9043: Github user asfgit closed the pull request at: https://github.com/apache/ignite/pull/4447 > Collections cannot be assigned to fields of type Object in BinaryObject > --- > > Key: IGNITE-9043 > URL: https://issues.apache.org/jira/browse/IGNITE-9043 > Project: Ignite > Issue Type: Bug > Components: binary >Affects Versions: 2.6 >Reporter: Denis Mekhanikov >Assignee: Denis Mekhanikov >Priority: Major > Labels: usability > Fix For: 2.7 > > > When a binary type is registered during first insertion without use of > BinaryObject, then fields of type {{Map}} are registered as {{Object}}-s. > But if you try to assign a {{HashMap}} to this field afterwards, then > exception is thrown. > The following code results in an exception: > {code:java} > public static void main(String[] args) { > Ignite ignite = Ignition.start("config/ignite.xml"); > IgniteCache cache = > ignite.getOrCreateCache("cache"); > cache.put(1, new ExamplePojo()); > BinaryObject val = cache.withKeepBinary().get(1); > Map map = val.field("map"); > BinaryObjectBuilder bldr = val.toBuilder(); > bldr.setField("map", map); > bldr.build(); // Throws exception. > } > static class ExamplePojo { > Map map = new HashMap<>(); > } > {code} > Stacktrace: > {noformat} > Exception in thread "main" class > org.apache.ignite.binary.BinaryObjectException: Wrong value has been set > [typeName=binary.BinaryObjectMapExample$ExamplePojo, fieldName=map, > fieldType=Object, assignedValueType=Map] > at > org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl.checkMetadata(BinaryObjectBuilderImpl.java:428) > at > org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl.serializeTo(BinaryObjectBuilderImpl.java:223) > at > org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl.build(BinaryObjectBuilderImpl.java:183) > at binary.BinaryObjectMapExample.main(BinaryObjectMapExample.java:26) > {noformat} > It would be convenient, if objects of any type could be written as {{Object}} > without the need to specify the type explicitly in > {{BinaryObjectBuilder.setField(...)}} method. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (IGNITE-9043) Collections cannot be assigned to fields of type Object in BinaryObject
[ https://issues.apache.org/jira/browse/IGNITE-9043?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16568207#comment-16568207 ] Vladimir Ozerov commented on IGNITE-9043: - [~dmekhanikov], looks good to me. > Collections cannot be assigned to fields of type Object in BinaryObject > --- > > Key: IGNITE-9043 > URL: https://issues.apache.org/jira/browse/IGNITE-9043 > Project: Ignite > Issue Type: Bug > Components: binary >Affects Versions: 2.6 >Reporter: Denis Mekhanikov >Assignee: Denis Mekhanikov >Priority: Major > Labels: usability > Fix For: 2.7 > > > When a binary type is registered during first insertion without use of > BinaryObject, then fields of type {{Map}} are registered as {{Object}}-s. > But if you try to assign a {{HashMap}} to this field afterwards, then > exception is thrown. > The following code results in an exception: > {code:java} > public static void main(String[] args) { > Ignite ignite = Ignition.start("config/ignite.xml"); > IgniteCache cache = > ignite.getOrCreateCache("cache"); > cache.put(1, new ExamplePojo()); > BinaryObject val = cache.withKeepBinary().get(1); > Map map = val.field("map"); > BinaryObjectBuilder bldr = val.toBuilder(); > bldr.setField("map", map); > bldr.build(); // Throws exception. > } > static class ExamplePojo { > Map map = new HashMap<>(); > } > {code} > Stacktrace: > {noformat} > Exception in thread "main" class > org.apache.ignite.binary.BinaryObjectException: Wrong value has been set > [typeName=binary.BinaryObjectMapExample$ExamplePojo, fieldName=map, > fieldType=Object, assignedValueType=Map] > at > org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl.checkMetadata(BinaryObjectBuilderImpl.java:428) > at > org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl.serializeTo(BinaryObjectBuilderImpl.java:223) > at > org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl.build(BinaryObjectBuilderImpl.java:183) > at binary.BinaryObjectMapExample.main(BinaryObjectMapExample.java:26) > {noformat} > It would be convenient, if objects of any type could be written as {{Object}} > without the need to specify the type explicitly in > {{BinaryObjectBuilder.setField(...)}} method. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (IGNITE-9043) Collections cannot be assigned to fields of type Object in BinaryObject
[ https://issues.apache.org/jira/browse/IGNITE-9043?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16568160#comment-16568160 ] Dmitry Karachentsev commented on IGNITE-9043: - [~dmekhanikov] Reviewed, looks OK for me. > Collections cannot be assigned to fields of type Object in BinaryObject > --- > > Key: IGNITE-9043 > URL: https://issues.apache.org/jira/browse/IGNITE-9043 > Project: Ignite > Issue Type: Bug > Components: binary >Affects Versions: 2.6 >Reporter: Denis Mekhanikov >Assignee: Denis Mekhanikov >Priority: Major > Labels: usability > Fix For: 2.7 > > > When a binary type is registered during first insertion without use of > BinaryObject, then fields of type {{Map}} are registered as {{Object}}-s. > But if you try to assign a {{HashMap}} to this field afterwards, then > exception is thrown. > The following code results in an exception: > {code:java} > public static void main(String[] args) { > Ignite ignite = Ignition.start("config/ignite.xml"); > IgniteCache cache = > ignite.getOrCreateCache("cache"); > cache.put(1, new ExamplePojo()); > BinaryObject val = cache.withKeepBinary().get(1); > Map map = val.field("map"); > BinaryObjectBuilder bldr = val.toBuilder(); > bldr.setField("map", map); > bldr.build(); // Throws exception. > } > static class ExamplePojo { > Map map = new HashMap<>(); > } > {code} > Stacktrace: > {noformat} > Exception in thread "main" class > org.apache.ignite.binary.BinaryObjectException: Wrong value has been set > [typeName=binary.BinaryObjectMapExample$ExamplePojo, fieldName=map, > fieldType=Object, assignedValueType=Map] > at > org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl.checkMetadata(BinaryObjectBuilderImpl.java:428) > at > org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl.serializeTo(BinaryObjectBuilderImpl.java:223) > at > org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl.build(BinaryObjectBuilderImpl.java:183) > at binary.BinaryObjectMapExample.main(BinaryObjectMapExample.java:26) > {noformat} > It would be convenient, if objects of any type could be written as {{Object}} > without the need to specify the type explicitly in > {{BinaryObjectBuilder.setField(...)}} method. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (IGNITE-9043) Collections cannot be assigned to fields of type Object in BinaryObject
[ https://issues.apache.org/jira/browse/IGNITE-9043?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16559839#comment-16559839 ] ASF GitHub Bot commented on IGNITE-9043: GitHub user dmekhanikov opened a pull request: https://github.com/apache/ignite/pull/4447 IGNITE-9043 let values of any type be written to Object field You can merge this pull request into a Git repository by running: $ git pull https://github.com/gridgain/apache-ignite IGNITE-9043 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/ignite/pull/4447.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #4447 commit 734f56495292d6cbaff34c73f5d6593432e78ee3 Author: Denis Mekhanikov Date: 2018-07-27T14:27:41Z IGNITE-9043 let values of any type be written to Object field > Collections cannot be assigned to fields of type Object in BinaryObject > --- > > Key: IGNITE-9043 > URL: https://issues.apache.org/jira/browse/IGNITE-9043 > Project: Ignite > Issue Type: Bug > Components: binary >Affects Versions: 2.6 >Reporter: Denis Mekhanikov >Assignee: Denis Mekhanikov >Priority: Major > Labels: usability > Fix For: 2.7 > > > When a binary type is registered during first insertion without use of > BinaryObject, then fields of type {{Map}} are registered as {{Object}}-s. > But if you try to assign a {{HashMap}} to this field afterwards, then > exception is thrown. > The following code results in an exception: > {code:java} > public static void main(String[] args) { > Ignite ignite = Ignition.start("config/ignite.xml"); > IgniteCache cache = > ignite.getOrCreateCache("cache"); > cache.put(1, new ExamplePojo()); > BinaryObject val = cache.withKeepBinary().get(1); > Map map = val.field("map"); > BinaryObjectBuilder bldr = val.toBuilder(); > bldr.setField("map", map); > bldr.build(); // Throws exception. > } > static class ExamplePojo { > Map map = new HashMap<>(); > } > {code} > Stacktrace: > {noformat} > Exception in thread "main" class > org.apache.ignite.binary.BinaryObjectException: Wrong value has been set > [typeName=binary.BinaryObjectMapExample$ExamplePojo, fieldName=map, > fieldType=Object, assignedValueType=Map] > at > org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl.checkMetadata(BinaryObjectBuilderImpl.java:428) > at > org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl.serializeTo(BinaryObjectBuilderImpl.java:223) > at > org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl.build(BinaryObjectBuilderImpl.java:183) > at binary.BinaryObjectMapExample.main(BinaryObjectMapExample.java:26) > {noformat} > It would be convenient, if objects of any type could be written as {{Object}} > without the need to specify the type explicitly in > {{BinaryObjectBuilder.setField(...)}} method. -- This message was sent by Atlassian JIRA (v7.6.3#76005)