Default CacheConfiguration instance can't be serialized

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Default CacheConfiguration instance can't be serialized

Nikolay Izhikov
Hello, Guys.

I found that CacheConfiguration which implements Serializable contains not
serializable fields by default.

CacheConfiguration -> affMapper -> CacheDefaultBinaryAffinityKeyMapper ->
proc -> CacheObjectBinaryProcessorImpl.

Is this a bug or I miss something?

Simple reproducer:

```
public class SimpleSerializableTet extends GridCommonAbstractTest {
    public void testRemoteFilterFactoryClient() throws Exception {
        Ignite g = startGrid(0);

        IgniteCache<Object, Object> cache =
g.getOrCreateCache("TEST_CACHE");
        CacheConfiguration ccfg =
cache.getConfiguration(CacheConfiguration.class);

        assertTrue(ccfg instanceof Serializable);
        assertTrue(ccfg.getAffinityMapper() instanceof Serializable);

        try (ByteArrayOutputStream bos = new ByteArrayOutputStream()) {
            ObjectOutput out = new ObjectOutputStream(bos);
            out.writeObject(ccfg);
            out.flush();
        }
    }
}

```
Exception is:

```
java.io.NotSerializableException:
org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1184)
```



--
Nikolay Izhikov
[hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Default CacheConfiguration instance can't be serialized

Dmitriy Pavlov
Hi Nikolay,

It is strange, because Cache Configuration is saved under
StoreConfiguration into persistent store cache_data file.

Did you find an anwser?

Sincerely,
Dmitriy Pavlov

вт, 26 сент. 2017 г. в 19:02, Николай Ижиков <[hidden email]>:

> Hello, Guys.
>
> I found that CacheConfiguration which implements Serializable contains not
> serializable fields by default.
>
> CacheConfiguration -> affMapper -> CacheDefaultBinaryAffinityKeyMapper ->
> proc -> CacheObjectBinaryProcessorImpl.
>
> Is this a bug or I miss something?
>
> Simple reproducer:
>
> ```
> public class SimpleSerializableTet extends GridCommonAbstractTest {
>     public void testRemoteFilterFactoryClient() throws Exception {
>         Ignite g = startGrid(0);
>
>         IgniteCache<Object, Object> cache =
> g.getOrCreateCache("TEST_CACHE");
>         CacheConfiguration ccfg =
> cache.getConfiguration(CacheConfiguration.class);
>
>         assertTrue(ccfg instanceof Serializable);
>         assertTrue(ccfg.getAffinityMapper() instanceof Serializable);
>
>         try (ByteArrayOutputStream bos = new ByteArrayOutputStream()) {
>             ObjectOutput out = new ObjectOutputStream(bos);
>             out.writeObject(ccfg);
>             out.flush();
>         }
>     }
> }
>
> ```
> Exception is:
>
> ```
> java.io.NotSerializableException:
>
> org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl
> at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1184)
> ```
>
>
>
> --
> Nikolay Izhikov
> [hidden email]
>