You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ignite.apache.org by "Denis Mekhanikov (JIRA)" <ji...@apache.org> on 2018/07/20 13:25:00 UTC
[jira] [Created] (IGNITE-9043) Map field is registered as Object in
BinaryType
Denis Mekhanikov created IGNITE-9043:
----------------------------------------
Summary: Map field is registered as Object in BinaryType
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
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.
It leads to inconvenience in further usage of this type over {{BinaryObject}} interface.
The following code results in an exception:
{code:java}
public static void main(String[] args) {
Ignite ignite = Ignition.start("config/ignite.xml");
IgniteCache<Integer, ExamplePojo> cache = ignite.getOrCreateCache("cache");
cache.put(1, new ExamplePojo());
BinaryObject val = cache.<Integer, BinaryObject>withKeepBinary().get(1);
Map<Integer, String> map = val.field("map");
map.put(1, "1");
BinaryObjectBuilder bldr = val.toBuilder();
bldr.setField("map", map);
bldr.build(); // Throws exception.
}
static class ExamplePojo {
Map<Integer, String> 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}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)