Correctly implement SelectedSelectionKeySet.remove(...) / contains(...) again so it works with the NIO Selector.

Motivation:

c1a335446d reimplemented remove(...) and contains(...) in a way which made it not work anymore when used by the Selector.

Modifications:

Partly revert changes in c1a335446d.

Result:

Works again as expected
This commit is contained in:
Norman Maurer 2018-09-01 08:33:32 +02:00
parent f4bafd4fe0
commit 187b1b8a55
2 changed files with 13 additions and 8 deletions

View File

@ -44,6 +44,16 @@ final class SelectedSelectionKeySet extends AbstractSet<SelectionKey> {
return true;
}
@Override
public boolean remove(Object o) {
return false;
}
@Override
public boolean contains(Object o) {
return false;
}
@Override
public int size() {
return size;

View File

@ -97,8 +97,8 @@ public class SelectedSelectionKeySetTest {
SelectedSelectionKeySet set = new SelectedSelectionKeySet();
assertTrue(set.add(mockKey));
assertTrue(set.add(mockKey2));
assertTrue(set.contains(mockKey));
assertTrue(set.contains(mockKey2));
assertFalse(set.contains(mockKey));
assertFalse(set.contains(mockKey2));
assertFalse(set.contains(mockKey3));
}
@ -106,12 +106,7 @@ public class SelectedSelectionKeySetTest {
public void remove() {
SelectedSelectionKeySet set = new SelectedSelectionKeySet();
assertTrue(set.add(mockKey));
assertFalse(set.remove(mockKey));
assertFalse(set.remove(mockKey2));
try {
set.remove(mockKey);
fail();
} catch (UnsupportedOperationException expected) {
// expected
}
}
}