[ 
https://issues.apache.org/jira/browse/PROTON-1958?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16651478#comment-16651478
 ] 

ASF GitHub Bot commented on PROTON-1958:
----------------------------------------

GitHub user jdanekrh opened a pull request:

    https://github.com/apache/qpid-proton-j/pull/19

    PROTON-1958 Fix use of AtomicInteger for instance IDs

    

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/jdanekrh/qpid-proton-j jd_staticatomic

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/qpid-proton-j/pull/19.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #19
    
----
commit e9724b7d26644e8f78fbccc356ab748e295801cd
Author: Jiri Danek <jdanek@...>
Date:   2018-10-15T09:30:43Z

    PROTON-1958 Fix use of AtomicInteger for instance IDs

----


> Equality in TaskImpl is potentially broken (all instances have the same 
> this.counter value)
> -------------------------------------------------------------------------------------------
>
>                 Key: PROTON-1958
>                 URL: https://issues.apache.org/jira/browse/PROTON-1958
>             Project: Qpid Proton
>          Issue Type: Bug
>          Components: proton-j
>    Affects Versions: proton-j-0.29.0
>            Reporter: Jiri Daněk
>            Priority: Major
>
> Looking at the implementation, it seems that every instance of TaskImpl has 
> {{this.counter == 0}}. This seems wrong. The {{count}} field should be static 
> for the instance id to work. 
> {code}
> public class TaskImpl implements Task, Comparable<TaskImpl> {
> [...]
>     private final AtomicInteger count = new AtomicInteger();
> [...]
>     public TaskImpl(long deadline) {
>         this.deadline = deadline;
>         this.counter = count.getAndIncrement();
>     }
>     @Override
>     public int compareTo(TaskImpl other) {
>         int result;
>         if (deadline < other.deadline) {
>             result = -1;
>         } else if (deadline > other.deadline) {
>             result = 1;
>         } else {
>             result = counter - other.counter;
>         }
>         return result;
>     }
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to