You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by "kcheng.mvp" <kc...@gmail.com> on 2018/09/19 07:21:18 UTC
***UNCHECKED*** new CacheConfiguration always returns same instance
here is a simple test code
CacheConfiguration cacheCfg = new CacheConfiguration<>(IG_P);
cacheCfg.setBackups(1);
cacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.PRIMARY_SYNC);
logger.info("instance {}", cacheCfg.hashCode());
cacheCfg = new CacheConfiguration<>(IG_T);
cacheCfg.setBackups(1);
cacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.PRIMARY_SYNC);
logger.info("instance {}", cacheCfg.hashCode());
the log shows even I create CacheConfiguration two times, but they have the
same hashcode. is this correct?
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
***UNCHECKED*** Re: new CacheConfiguration always returns same
instance
Posted by akurbanov <an...@gmail.com>.
Hello,
Why would you expect them to be different in your test? This is not a
violation of hashcode general contract. They are calculated using
MutableConfiguration
<https://static.javadoc.io/javax.cache/cache-api/1.0.0/javax/cache/configuration/MutableConfiguration.html>
.hashCode() from JSR 107
<https://jcp.org/aboutJava/communityprocess/final/jsr107/index.html> , you
may check here for source code executed at this point:
MutableConfiguration.java
<https://github.com/jsr107/jsr107spec/blob/master/src/main/java/javax/cache/configuration/MutableConfiguration.java>
Regards,
Anton
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Re: ***UNCHECKED*** new CacheConfiguration always returns same instance
Posted by Ilya Kasnacheev <il...@gmail.com>.
Hello!
MutableConfiguration does not include cache name so it is not used when
computing hash code.
Since this is an implementation detail that is never documented I think it
is a very minor issue from our side. Still, you can fill an issue against
Apache Ignite JIRA if you like.
Regards,
I think this
--
Ilya Kasnacheev
вс, 23 сент. 2018 г. в 21:22, kcheng.mvp <kc...@gmail.com>:
> As I pass different cache name as the parameter, so I suppose the hash code
> should be different.
>
>
> in my use case i create Spring bean via @Bean with @Scope(value =
> SCOPE_PROTOTYPE)
>
> when I try to verify if a new instance is created or not I found the hash
> code is the same.
> that's why I ask this question.
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>
Re: ***UNCHECKED*** new CacheConfiguration always returns same
instance
Posted by "kcheng.mvp" <kc...@gmail.com>.
As I pass different cache name as the parameter, so I suppose the hash code
should be different.
in my use case i create Spring bean via @Bean with @Scope(value =
SCOPE_PROTOTYPE)
when I try to verify if a new instance is created or not I found the hash
code is the same.
that's why I ask this question.
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Re: ***UNCHECKED*** new CacheConfiguration always returns same instance
Posted by Ilya Kasnacheev <il...@gmail.com>.
Hello!
hashCode is implemented by MutableConfiguration (from JCache) which only
takes a subset of fields into account.
Why is this a problem for you?
Regards,
--
Ilya Kasnacheev
ср, 19 сент. 2018 г. в 10:21, kcheng.mvp <kc...@gmail.com>:
> here is a simple test code
>
> CacheConfiguration cacheCfg = new CacheConfiguration<>(IG_P);
> cacheCfg.setBackups(1);
>
>
> cacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.PRIMARY_SYNC);
> logger.info("instance {}", cacheCfg.hashCode());
>
> cacheCfg = new CacheConfiguration<>(IG_T);
> cacheCfg.setBackups(1);
>
>
> cacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.PRIMARY_SYNC);
> logger.info("instance {}", cacheCfg.hashCode());
>
>
> the log shows even I create CacheConfiguration two times, but they have the
> same hashcode. is this correct?
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>