You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Stepan Mishura (JIRA)" <ji...@apache.org> on 2006/09/20 08:19:23 UTC
[jira] Updated: (HARMONY-1498) [classlib][luni][HashMap]It is not
appropriate to use entrySet as judgement in HashMap.putAll()
[ http://issues.apache.org/jira/browse/HARMONY-1498?page=all ]
Stepan Mishura updated HARMONY-1498:
------------------------------------
Component/s: Classlib
> [classlib][luni][HashMap]It is not appropriate to use entrySet as judgement in HashMap.putAll()
> -----------------------------------------------------------------------------------------------
>
> Key: HARMONY-1498
> URL: http://issues.apache.org/jira/browse/HARMONY-1498
> Project: Harmony
> Issue Type: Bug
> Components: Classlib
> Reporter: Leo Li
>
> We have:
> if (map.entrySet() != null) {...} in HashMap.putAll().
> The most important thing is that It is tedious to get the entrySet from HashMap just to make a judgement.
> Here I give out a testcase which I admit is too some degree extreme, however it is enough to show that to use entrySet as a judgement is not appropriate.
> private static class MockMap extends AbstractMap
> {
> public Set entrySet() {
>
> return null;
> }
>
> public int size()
> {
> return 10;
> }
> }
>
> public void testPutAll()
> {
> HashMap hashMap = new HashMap();
> try
> {
> hashMap.putAll(new MockMap());
> fail("should throw NullPointerException");
> }
> catch(NullPointerException e)
> {
> //expected.
> }
>
>
> try
> {
> hashMap = new HashMap(new MockMap());
> fail("should throw NullPointerException");
> }
> catch(NullPointerException e)
> {
> //expected.
> }
> }
> RI passes
> Harmony fails
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira