anton-vinogradov commented on PR #13447:
URL: https://github.com/apache/ignite/pull/13447#issuecomment-5241705166

   `assert initTime > 0` in `expireTime()` fires for a cache without an expiry 
policy.
   
   The constructor sets `initTime` only when there is an expiration:
   
   ```java
   if (expireTime != 0) {
       initTime = U.currentTimeMillis();
       ...
   }
   ```
   
   so for a never expiring entry it stays 0, and the assert runs before the 
`-1` check:
   
   ```java
   public long expireTime() {
       assert initTime > 0;            // <- here
       assert expireTimeDelta >= -1L;
   
       return expireTimeDelta == -1L ? 0L : initTime + expireTimeDelta;
   }
   ```
   
   That hits any locally built info of a cache with no expiry policy, 
`GridCacheMapEntry.info()` read through 
`GridNearCacheEntry.initializeFromDht:156`. Assertions are on in a normal test 
run, I did not have to pass `-ea`:
   
   ```
   java.lang.AssertionError
        at 
org.apache.ignite.internal.processors.cache.GridCacheEntryInfo.expireTime(GridCacheEntryInfo.java:131)
        at ...GridCacheEntryInfoSerializationTest.testLocalNeverExpiringEntry
   ```
   
   with
   
   ```java
   assertEquals(0, new GridCacheEntryInfo(cacheId, key, val, ver, 0, 
0).expireTime());
   ```
   
   Setting `initTime` unconditionally fixes it and costs one volatile read.
   
   Thanks for taking the `-1` sentinel, the clamp and `U.currentTimeMillis()`, 
the never expiring entry is a single byte on the wire again.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to