harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Leo Li (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HARMONY-1498) [classlib][luni][HashMap]It is not appropriate to use entrySet as judgement in HashMap.putAll()
Date Thu, 21 Sep 2006 02:35:24 GMT
    [ http://issues.apache.org/jira/browse/HARMONY-1498?page=comments#action_12436426 ] 
            
Leo Li commented on HARMONY-1498:
---------------------------------

Verified.

> [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
>         Assigned To: Paulex Yang
>         Attachments: patch.diff
>
>
> 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

        

Mime
View raw message