accumulo-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Keith Turner (JIRA)" <>
Subject [jira] [Commented] (ACCUMULO-2131) while statement used as if statement
Date Mon, 10 Feb 2014 20:59:19 GMT


Keith Turner commented on ACCUMULO-2131:

bq. While source changes, the loop condition will never be checked again after the return

oh yeah,  well that was not my intent.  I wanted it to recheck.   However for correctness,
the source does not need to be rechecked.  If after getting the new source it becomes invalid
then either one key or a row will be read before switching.   Its just not switching as soon
as it could in this special case.  

My thinking was that getting the iterator could take a bit of time because it may involve
I/O.  Therefore the new datasource could be invalidated by other concurrent actions (like
bulk import or compactions).   I am not really sure if its worth handling this special case.
  I would not be opposed to just changing to an if.

> while statement used as if statement
> ------------------------------------
>                 Key: ACCUMULO-2131
>                 URL:
>             Project: Accumulo
>          Issue Type: Bug
>          Components: tserver
>            Reporter: Eric Newton
>            Assignee: Keith Turner
>            Priority: Trivial
>             Fix For: 1.6.0
> Going through PMD output, and this looks a little sketchy in
> {noformat}
>   private boolean switchSource() throws IOException {
>     while (!source.isCurrent()) {
>       source = source.getNewDataSource();
>       iter = source.iterator();
>       if (iflag != null)
>         ((InterruptibleIterator) iter).setInterruptFlag(iflag);
>       return true;
>     }
>     return false;
>   }
> {noformat}
> I'm wondering if that "while" should be "if"

This message was sent by Atlassian JIRA

View raw message