[GitHub] commons-collections pull request #28: COLLECTIONS-661: fix for concurrency i...

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[GitHub] commons-collections pull request #28: COLLECTIONS-661: fix for concurrency i...

chonton
GitHub user kinow opened a pull request:

    https://github.com/apache/commons-collections/pull/28

    COLLECTIONS-661: fix for concurrency issue in HashSetValuedHashMapTest

    The `getMap()` method, when testing a `HashSetValuedHashMap`, would return an object of this type. Which is an instance of `SetValuedMap`.
   
    Running it in debug mode would - most of the times - run the tests and succeed. Running normally - especially on Windows - would result in intermittent, but very frequent, failures.
   
    The `getMap()` method sometimes, depending on the order and execution of tests, will be null. So the collection added to the map will be either a `Hashset`, or a `Arrays$ArrayList`. When the types are different, `hashCode()` and `equals()` calls return incorrect values, resulting in the errors we have seen in COLLECTIONS-661.
   
    A good solution would be to re-design the tests. The `TestMultiValuedMapAsMap` is testing `MultiValuedMap`'s, which include `HashSetValuedHashMap`. However, some of its methods contain extra logic for when the type under test has some characteristics like being an instance of `SetValuedMap`.
   
    It might be possible to come up with a better design, where there are multiple test classes, for `MultiValuedMap`'s that use `SetValuedMap`'s; `MultieValuedMap`'s that use `List`'s, and so it goes.
   
    Or we could add a class to the parent class, with a flag defining the type under test. For now, I have used the `makeObject()` method, which returns the collection under test. Then I validate its instance type. There is also a comment above the code to indicate why we are using `makeObject()` and not `getMap()`.
   
    It was a fun ticket. Happy to get feedback on better solutions, or feel free to edit this pull request if you have right to it, or merge if you are happy and it has gathered some consensus.
   
    Cheers,
    Bruno

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

    $ git pull https://github.com/kinow/commons-collections COLLECTIONS-661

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

    https://github.com/apache/commons-collections/pull/28.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 #28
   
----
commit 6e8951ed0325abe3e07e32aded0b27aacdbc1011
Author: Bruno P. Kinoshita <[hidden email]>
Date:   2017-10-11T07:27:25Z

    COLLECTIONS-661: fix for concurrency issue in HashSetValuedHashMapTest

----


---

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

Reply | Threaded
Open this post in threaded view
|

[GitHub] commons-collections issue #28: COLLECTIONS-661: fix for concurrency issue in...

chonton
Github user coveralls commented on the issue:

    https://github.com/apache/commons-collections/pull/28
 
   
    [![Coverage Status](https://coveralls.io/builds/13663731/badge)](https://coveralls.io/builds/13663731)
   
    Coverage increased (+0.008%) to 85.126% when pulling **6e8951ed0325abe3e07e32aded0b27aacdbc1011 on kinow:COLLECTIONS-661** into **1d21a49c27d9eab8d02785a783fcfba387a3e8e1 on apache:master**.



---

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

Reply | Threaded
Open this post in threaded view
|

[GitHub] commons-collections issue #28: COLLECTIONS-661: fix for concurrency issue in...

chonton
In reply to this post by chonton
Github user kinow commented on the issue:

    https://github.com/apache/commons-collections/pull/28
 
    Merged inhttps://github.com/apache/commons-collections/commit/eed8a7adb3de7441751e846f4a75d110dd205f23. Closing it.


---

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

Reply | Threaded
Open this post in threaded view
|

[GitHub] commons-collections pull request #28: COLLECTIONS-661: fix for concurrency i...

chonton
In reply to this post by chonton
Github user kinow closed the pull request at:

    https://github.com/apache/commons-collections/pull/28


---

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

Reply | Threaded
Open this post in threaded view
|

[GitHub] commons-collections pull request #28: COLLECTIONS-661: fix for concurrency i...

chonton
In reply to this post by chonton
Github user kinow closed the pull request at:

    https://github.com/apache/commons-collections/pull/28


---

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