[ 
https://issues.apache.org/jira/browse/IGNITE-12468?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17029056#comment-17029056
 ] 

Ivan Pavlukhin commented on IGNITE-12468:
-----------------------------------------

[~alex_pl], I checked some corner cases and found 2 generally unpleasant 
things. 
List having a direct reference to itself among elements leads to 
{{StackOverflowError}}.
{code}
List<Object> l = new ArrayList<>();
l.add(l);
{code}
List having indirect self-reference leads to creation of 2 list objects instead 
of only one as was initially.
{code}
List<Object> l = new ArrayList<>();
l.add(new Wrapper(l));
{code}
I.e. after put/get into a cache we will receive a top level _list1_ containing 
a _wrapper_ wrapping _list2_. _list2_ will contain the same _wrapper_.

Good news for us are that both peculiarities takes place for a thick client as 
well.

Additionally, I noticed a following. In PR there are changes on a 
{{ClientUtils#readObject}} execution path handling nested deserialization of 
collections. And as I understood it has an effect only for top-level 
collections (a value inserted into a cache is a collection). If a collection is 
wrapped into binary object, then a collection deserialization will go another 
path. And actually it looks like a duplication again. In my mind we need 2 
things here. Fist is a justification of the duplication if it is unavoidable. 
Second is tests ensuring that thin and thick client behave the same.

> ClassCastException on thinClient in Apache Ignite
> -------------------------------------------------
>
>                 Key: IGNITE-12468
>                 URL: https://issues.apache.org/jira/browse/IGNITE-12468
>             Project: Ignite
>          Issue Type: Bug
>          Components: binary, clients, thin client
>    Affects Versions: 2.6
>            Reporter: LEE PYUNG BEOM
>            Assignee: Aleksey Plekhanov
>            Priority: Major
>
>  
> {code:java}
>     ClientConfiguration cfg = new 
> ClientConfiguration().setAddresses("127.0.0.1:10800");
>     try (IgniteClient igniteClient = Ignition.startClient(cfg)) {
>         System.out.println(">>> Thin client put-get example started.");
>         final String CACHE_NAME = "put-get-example";
>         ClientCache<Integer, Object> cache = 
> igniteClient.getOrCreateCache(CACHE_NAME);
>         Person p = new Person();
>         //put
>         HashMap<Integer, Person> hm = new HashMap<Integer, Person>();
>         hm.put(1, p);
>         cache.put(1, hm);
>         //get
>         HashMap<Integer, Person> map = (HashMap<Integer, Person>)cache.get(1);
>         Person p2 = map.get(1);
>         System.out.format(">>> Loaded [%s] from the cache.\n",p2);
>     }
>     catch (ClientException e) {
>         System.err.println(e.getMessage());
>         e.printStackTrace();
>     }
>     catch (Exception e) {
>         System.err.format("Unexpected failure: %s\n", e);
>         e.printStackTrace();
>     }
> {code}
>  
> I use the thin client of apache-ignite.
> I Create a hashmap and put the Person 
> class(org.apache.ignite.examples.model.Person) object into it.
> And when I take it out of the hashmap, I get the following exceptions:
>  
> {code:java}
> > java.lang.ClassCastException:
> > org.apache.enite.internal.binary.BinaryObjectImpl cannot be cast to
> > org.apache.engite.examples.model.Person.
> {code}
> An exception is given in the code below.
>  
> {code:java}
> Person p2 = map.get(1);
> {code}
>  
> However, there is no exception if I modify the code as follows:
>  
> {code:java}
> BinaryObject bo = (BinaryObject) map.get(1);
> Person p2 = bo.deserialize();
> {code}
> I don't think that's necessary. Is there another solution?
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to