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

com.hazelcast.core.EntryView#getLastAccessTime is invalid #2581

Closed
OlegYch opened this issue May 29, 2014 · 4 comments
Closed

com.hazelcast.core.EntryView#getLastAccessTime is invalid #2581

OlegYch opened this issue May 29, 2014 · 4 comments
Assignees
Milestone

Comments

@OlegYch
Copy link

OlegYch commented May 29, 2014

using 3.3-EA the method returns values like 314897071 which does not seem like a plausible access time in any imaginable unit
similarly all other time values in entryview return something unusable
creationTime=314894976,expirationTime=0,hits=53,lastAccessTime=314897071,lastStoredTime=0,lastUpdateTime=314896015,version=16,evictionCriteriaNumber=53,ttl=0

@jerrinot
Copy link
Contributor

Here is a failing test:

    @Test
    public void testIssue2581() throws Exception {
        long startTime = new Date().getTime();

        IMap<String, String> map = createHazelcastInstance().getMap("map");
        map.put("foo", "bar");
        EntryView<String, String> foo = map.getEntryView("foo");
        assertTrue(foo.getCreationTime() >= startTime);
    }

The reason is the MapService uses System.nanoTime() to set a timestamps and entryView treat it as "number of nanoseconds since epoch". However the JavaDoc in System::nanoTime() says:

"This method can only be used to measure elapsed time and is not related to any other notion of system or wall-clock time. The value returned represents nanoseconds since some fixed but arbitrary origin time (perhaps in the future, so values may be negative)."

Therefore nanoTime() cannot be used to obtain a (global) timestamp.

@pveentjer
Copy link
Contributor

Jaromir the Hawk :)

@pveentjer pveentjer added this to the 3.3 milestone May 29, 2014
@jerrinot
Copy link
Contributor

It made my lunch sandwich slightly less delicious!

@ahmetmircik
Copy link
Member

Fixed by #2645

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

No branches or pull requests

4 participants