[jira] [Updated] (COLLECTIONS-802) ReferenceMap iterator remove violates contract

2022-04-28 Thread Bruno P. Kinoshita (Jira)


 [ 
https://issues.apache.org/jira/browse/COLLECTIONS-802?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Bruno P. Kinoshita updated COLLECTIONS-802:
---
Assignee: Bruno P. Kinoshita

> ReferenceMap iterator remove violates contract
> --
>
> Key: COLLECTIONS-802
> URL: https://issues.apache.org/jira/browse/COLLECTIONS-802
> Project: Commons Collections
>  Issue Type: Bug
>  Components: Map
>Affects Versions: 4.4
>Reporter: Ben Manes
>Assignee: Bruno P. Kinoshita
>Priority: Minor
> Attachments: ApacheMapTest-1.java, ApacheMapTest.java
>
>  Time Spent: 1h 50m
>  Remaining Estimate: 0h
>
> Out of curiosity I ran Guava's testlib Map tests against the Apache types. 
> This uncovered a contract bug where {{Iterator.remove()}} is invalidated by 
> {{{}hasNext(){}}}, causing its call to no-op due to {{currentKey}} becoming 
> {{{}null{}}}. The isolates case is,
> {code:java}
> @Test
> public void iterator_remove() {
>   var map = new ReferenceMap<>();
>   map.put(1, 2);
>   var iter = map.entrySet().iterator();
>   assertTrue(iter.hasNext());
>   assertTrue(iter.hasNext());
>   assertEquals(iter.next(), 1);
>   assertFalse(iter.hasNext());
>   iter.remove();
>   assertEquals(map, Map.of());
> }{code}
> Guava's [testlib|https://github.com/google/guava/tree/master/guava-testlib] 
> has good coverage for the Collections Framework and might be worth 
> integrating. The simple test case that I wrote is attached.



--
This message was sent by Atlassian Jira
(v8.20.7#820007)


[jira] [Updated] (COLLECTIONS-802) ReferenceMap iterator remove violates contract

2022-04-24 Thread Ben Manes (Jira)


 [ 
https://issues.apache.org/jira/browse/COLLECTIONS-802?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Ben Manes updated COLLECTIONS-802:
--
Attachment: ApacheMapTest-1.java

> ReferenceMap iterator remove violates contract
> --
>
> Key: COLLECTIONS-802
> URL: https://issues.apache.org/jira/browse/COLLECTIONS-802
> Project: Commons Collections
>  Issue Type: Bug
>  Components: Map
>Affects Versions: 4.4
>Reporter: Ben Manes
>Priority: Minor
> Attachments: ApacheMapTest-1.java, ApacheMapTest.java
>
>  Time Spent: 1h 10m
>  Remaining Estimate: 0h
>
> Out of curiosity I ran Guava's testlib Map tests against the Apache types. 
> This uncovered a contract bug where {{Iterator.remove()}} is invalidated by 
> {{{}hasNext(){}}}, causing its call to no-op due to {{currentKey}} becoming 
> {{{}null{}}}. The isolates case is,
> {code:java}
> @Test
> public void iterator_remove() {
>   var map = new ReferenceMap<>();
>   map.put(1, 2);
>   var iter = map.entrySet().iterator();
>   assertTrue(iter.hasNext());
>   assertTrue(iter.hasNext());
>   assertEquals(iter.next(), 1);
>   assertFalse(iter.hasNext());
>   iter.remove();
>   assertEquals(map, Map.of());
> }{code}
> Guava's [testlib|https://github.com/google/guava/tree/master/guava-testlib] 
> has good coverage for the Collections Framework and might be worth 
> integrating. The simple test case that I wrote is attached.



--
This message was sent by Atlassian Jira
(v8.20.7#820007)


[jira] [Updated] (COLLECTIONS-802) ReferenceMap iterator remove violates contract

2021-12-30 Thread Ben Manes (Jira)


 [ 
https://issues.apache.org/jira/browse/COLLECTIONS-802?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Ben Manes updated COLLECTIONS-802:
--
Description: 
Out of curiosity I ran Guava's testlib Map tests against the Apache types. This 
uncovered a contract bug where {{Iterator.remove()}} is invalidated by 
{{{}hasNext(){}}}, causing its call to no-op due to {{currentKey}} becoming 
{{{}null{}}}. The isolates case is,
{code:java}
@Test
public void iterator_remove() {
  var map = new ReferenceMap<>();
  map.put(1, 2);
  var iter = map.entrySet().iterator();
  assertTrue(iter.hasNext());
  assertTrue(iter.hasNext());
  assertEquals(iter.next(), 1);
  assertFalse(iter.hasNext());
  iter.remove();
  assertEquals(map, Map.of());
}{code}
Guava's [testlib|https://github.com/google/guava/tree/master/guava-testlib] has 
good coverage for the Collections Framework and might be worth integrating. The 
simple test case that I wrote is attached.

  was:
Out of curiosity I ran Guava's testlib Map tests against the Apache types. This 
uncovered a contract bug {{remove()}} is invalidated by {{hasNext()}} so its 
call will no-op (currentKey is {{{}null{}}}). The isolates case is,
{code:java}
@Test
public void iterator_remove() {
  var map = new ReferenceMap<>();
  map.put(1, 2);
  var iter = map.entrySet().iterator();
  assertTrue(iter.hasNext());
  assertTrue(iter.hasNext());
  assertEquals(iter.next(), 1);
  assertFalse(iter.hasNext());
  iter.remove();
  assertEquals(map, Map.of());
}{code}
Guava's testlib has good coverage for the Collections Framework and might be 
worth integrating. The simple test case that I wrote is attached.


> ReferenceMap iterator remove violates contract
> --
>
> Key: COLLECTIONS-802
> URL: https://issues.apache.org/jira/browse/COLLECTIONS-802
> Project: Commons Collections
>  Issue Type: Bug
>  Components: Map
>Affects Versions: 4.4
>Reporter: Ben Manes
>Priority: Minor
> Attachments: ApacheMapTest.java
>
>
> Out of curiosity I ran Guava's testlib Map tests against the Apache types. 
> This uncovered a contract bug where {{Iterator.remove()}} is invalidated by 
> {{{}hasNext(){}}}, causing its call to no-op due to {{currentKey}} becoming 
> {{{}null{}}}. The isolates case is,
> {code:java}
> @Test
> public void iterator_remove() {
>   var map = new ReferenceMap<>();
>   map.put(1, 2);
>   var iter = map.entrySet().iterator();
>   assertTrue(iter.hasNext());
>   assertTrue(iter.hasNext());
>   assertEquals(iter.next(), 1);
>   assertFalse(iter.hasNext());
>   iter.remove();
>   assertEquals(map, Map.of());
> }{code}
> Guava's [testlib|https://github.com/google/guava/tree/master/guava-testlib] 
> has good coverage for the Collections Framework and might be worth 
> integrating. The simple test case that I wrote is attached.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Updated] (COLLECTIONS-802) ReferenceMap iterator remove violates contract

2021-12-30 Thread Ben Manes (Jira)


 [ 
https://issues.apache.org/jira/browse/COLLECTIONS-802?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Ben Manes updated COLLECTIONS-802:
--
Summary: ReferenceMap iterator remove violates contract  (was: ReferenceMap 
iterator remove may fail)

> ReferenceMap iterator remove violates contract
> --
>
> Key: COLLECTIONS-802
> URL: https://issues.apache.org/jira/browse/COLLECTIONS-802
> Project: Commons Collections
>  Issue Type: Bug
>  Components: Map
>Affects Versions: 4.4
>Reporter: Ben Manes
>Priority: Minor
> Attachments: ApacheMapTest.java
>
>
> Out of curiosity I ran Guava's testlib Map tests against the Apache types. 
> This uncovered a contract bug {{remove()}} is invalidated by {{hasNext()}} so 
> its call will no-op (currentKey is {{{}null{}}}). The isolates case is,
> {code:java}
> @Test
> public void iterator_remove() {
>   var map = new ReferenceMap<>();
>   map.put(1, 2);
>   var iter = map.entrySet().iterator();
>   assertTrue(iter.hasNext());
>   assertTrue(iter.hasNext());
>   assertEquals(iter.next(), 1);
>   assertFalse(iter.hasNext());
>   iter.remove();
>   assertEquals(map, Map.of());
> }{code}
> Guava's testlib has good coverage for the Collections Framework and might be 
> worth integrating. The simple test case that I wrote is attached.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)