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

Fix long overflow by specifying getting state upto Instant.now() #18

Merged
merged 1 commit into from
Jun 8, 2016

Conversation

faraway
Copy link
Contributor

@faraway faraway commented Jun 2, 2016

I found this few weeks back when I was doing something similar to the concursus-spring-boot-demo app. Then I saw someone has the same problem as reported in issue #17

The problem is quite straightforward, when we call groupStateRepository.getStates(groups) in test code, it in turn calls getState(groups, Instant.MAX), where Instant.MAX is the upper bound. Later on when in CassandraEventRetriever.constrainBound, it calls bound.getInstant().toEpochMilli()) which results in the long overflow exception.
The problem can be simply reproduced by Instant.MAX.toEpochMilli())

Anyways, I'm not sure if Instant.MAX is intended. From the code comments, it seems to be Instant.now(), which translates to "get the events up to now". whereas Instant.MAX means to the far future based on its own documentation.

At the meantime, a simple workaround (as currently what i'm doing) is to specify the upper bound (i.e. do groupStateRepository.getStates(groups, Instant.now()) instead). The error goes away

@poetix poetix merged commit 0f50e49 into opencredo:master Jun 8, 2016
@poetix
Copy link
Contributor

poetix commented Jun 8, 2016

Thanks very much for this! It's surprising (to me) that Instant can encode a time value that isn't expressible in long millis-since-epoch; also surprising that I hadn't noticed this issue myself...

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

Successfully merging this pull request may close these issues.

None yet

2 participants