Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ExpirationTime not honored even after calling get() #10817

Closed
bradwee2000 opened this issue Jun 23, 2017 · 2 comments
Closed

ExpirationTime not honored even after calling get() #10817

bradwee2000 opened this issue Jun 23, 2017 · 2 comments

Comments

@bradwee2000
Copy link

@bradwee2000 bradwee2000 commented Jun 23, 2017

Hi, I'm using version 3.8.1 and noticed that calling replace(K, old, new) keeps the expiry time as creation time + duration. But hazelcast doesn't seem to honor this expiry even after calling get().

This test will fail:

@Test
public void testExpirationTimeOfReplace() throws Exception {
  IMap<Integer, Integer> map = hazelcastInstance.getMap("TEST_MAP");

  map.put(1, 1, 5, TimeUnit.SECONDS);

  sleepMillis(4000);
  boolean success = map.replace(1, 1, 2);
  assertEquals(success, true); //PASS

  sleepMillis(4000);
  success = map.replace(1, 2, 3);
  assertEquals(success, true); //PASS

  EntryView<Integer, Integer> entryView = map.getEntryView(1);
  long expectedExpirationTime = entryView.getCreationTime() + TimeUnit.SECONDS.toMillis(5);

  assertEquals(expectedExpirationTime, entryView.getExpirationTime()); // PASS

  assertTrue(map.get(1) == null); // FAIL
}

public static void sleepMillis(int millis) {
  try {
    TimeUnit.MILLISECONDS.sleep(millis);
  } catch (InterruptedException e) {
    Thread.currentThread().interrupt();
  }
}
@mdogan mdogan added the Team: Core label Jun 23, 2017
@ahmetmircik
Copy link
Member

@ahmetmircik ahmetmircik commented Jun 23, 2017

Hi,
Updates shift expiration-time. True expiration time can be calculated like this:
long expectedExpirationTime = entryView.getLastUpdateTime() + TimeUnit.SECONDS.toMillis(5);

The problem here is not-updated expiration-time returned from getEntryView operation.

Thanks for reporting. We will send a fix for that.

@ahmetmircik
Copy link
Member

@ahmetmircik ahmetmircik commented Jun 23, 2017

fixed by #10820

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.