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

Alexey Goncharuk commented on IGNITE-7401:
------------------------------------------

The reason for this is that a cache with no expiry policy treats TTL as 'TTL 
did not change'. I am not sure if we can determine if this behavior is correct 
because JSR107 does not allow to change expiry policy at runtime.

 

A workaround would be to use the following expiry policy:

{code}

public class ClearExpiryPolicy implements ExpiryPolicy, Serializable {

    @Override public Duration getExpiryForCreation() {

        return ETERNAL;

    }

    @Override public Duration getExpiryForAccess() {

        return ETERNAL;

    }

    @Override public Duration getExpiryForUpdate() {

        return ETERNAL;

    }

}

{code}

> Entry can be expired even if it doesn't define expiry policy in 
> "putWithPolicy-then-put" scenario
> -------------------------------------------------------------------------------------------------
>
>                 Key: IGNITE-7401
>                 URL: https://issues.apache.org/jira/browse/IGNITE-7401
>             Project: Ignite
>          Issue Type: Bug
>            Reporter: Andrey Gura
>            Priority: Major
>
> Entry can be expired even if it doesn't define expiry policy in 
> "putWithPolicy-then-put" scenario. The following test case demonstrate the 
> problem.
> {code:java}
>     public void testPutWithTtlThenPut() throws Exception {
>         Ignite ignite = startGrid();
>         try {
>             IgniteCache<Object, Object> cache = ignite.cache("cache");
>             CreatedExpiryPolicy expiryPlc = new CreatedExpiryPolicy(new 
> Duration(TimeUnit.MILLISECONDS, 10));
>             IgniteCache<Object, Object> cacheTtl = 
> cache.withExpiryPolicy(expiryPlc);
>             cacheTtl.put("key", "v1");
>             cache.put("key", "v2");
>             U.sleep(10);
>             assertEquals("v2", cache.get("key")); // Will fail (flaky)
>         }
>         finally {
>             stopAllGrids();
>         }
>     }
> {code}
> The issue also affects Ignite based cluster manager for Vert.x: 
> https://github.com/vert-x3/vertx-ignite/issues/63



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to