hbase-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "nkeywal (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HBASE-6476) Replace all occurrances of System.currentTimeMillis() with EnvironmentEdge equivalent
Date Thu, 06 Sep 2012 07:29:08 GMT

    [ https://issues.apache.org/jira/browse/HBASE-6476?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13449489#comment-13449489

nkeywal commented on HBASE-6476:

I think we're actually on the same line :-).
In src/main code, we should NEVER use System.currentTimeMillis().
In src/test code, we sometimes use it to measure the time spent in the function. For example:

// some test code
final long max = System.currentTimeMillis() + 10000;
while (!condition){ // condition is modified by another thread from src/main
 Assert.assertTrue( System.currentTimeMillis() < max, " condition not met after 10s, exiting);
// more test code

I've wrote quite a lot of code like this. It helps the test to fail fast and clearly. In a
way, that comes from JUnit/Surefire limitations. But at the end of the day, there is no reason
to use EnvEdge here. On the contrary, we should NOT use it here. Because we could imagine
a test that needs both to have a specific EnvEdge to fake the time for the src/main method,
but still need to check that we're not spending too much 'real' time in it.

What do you think?
> Replace all occurrances of System.currentTimeMillis() with EnvironmentEdge equivalent
> -------------------------------------------------------------------------------------
>                 Key: HBASE-6476
>                 URL: https://issues.apache.org/jira/browse/HBASE-6476
>             Project: HBase
>          Issue Type: Bug
>            Reporter: Lars Hofhansl
>            Assignee: Lars Hofhansl
>            Priority: Minor
>             Fix For: 0.96.0
>         Attachments: 6476.txt, 6476-v2.txt, 6476-v2.txt
> There are still some areas where System.currentTimeMillis() is used in HBase. In order
to make all parts of the code base testable and (potentially) to be able to configure HBase's
notion of time, this should be generally be replaced with EnvironmentEdgeManager.currentTimeMillis().
> How hard would it be to add a maven task that checks for that, so we do not introduce
System.currentTimeMillis back in the future?

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

View raw message