You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Leo Li (JIRA)" <ji...@apache.org> on 2006/09/20 04:55:26 UTC

[jira] Created: (HARMONY-1498) [classlib][luni][HashMap]It is not appropriate to use entrySet as judgement in HashMap.putAll()

[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
            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

        

[jira] Updated: (HARMONY-1498) [classlib][luni][HashMap]It is not appropriate to use entrySet as judgement in HashMap.putAll()

Posted by "Stepan Mishura (JIRA)" <ji...@apache.org>.
     [ 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

        

[jira] Updated: (HARMONY-1498) [classlib][luni][HashMap]It is not appropriate to use entrySet as judgement in HashMap.putAll()

Posted by "Leo Li (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HARMONY-1498?page=all ]

Leo Li updated HARMONY-1498:
----------------------------

    Attachment: patch.diff

Hi,
    Would someone like to try the patch?:)

> [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
>         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

        

[jira] Resolved: (HARMONY-1498) [classlib][luni][HashMap]It is not appropriate to use entrySet as judgement in HashMap.putAll()

Posted by "Paulex Yang (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HARMONY-1498?page=all ]

Paulex Yang resolved HARMONY-1498.
----------------------------------

    Resolution: Fixed

Leo, patch applied at revision r448131, thanks a lot for this enhancement, please verify that the problem is fully fixed as you expected.


> [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

        

[jira] Assigned: (HARMONY-1498) [classlib][luni][HashMap]It is not appropriate to use entrySet as judgement in HashMap.putAll()

Posted by "Paulex Yang (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HARMONY-1498?page=all ]

Paulex Yang reassigned HARMONY-1498:
------------------------------------

    Assignee: Paulex Yang

> [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

        

[jira] Commented: (HARMONY-1498) [classlib][luni][HashMap]It is not appropriate to use entrySet as judgement in HashMap.putAll()

Posted by "Leo Li (JIRA)" <ji...@apache.org>.
    [ 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

        

[jira] Closed: (HARMONY-1498) [classlib][luni][HashMap]It is not appropriate to use entrySet as judgement in HashMap.putAll()

Posted by "Paulex Yang (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HARMONY-1498?page=all ]

Paulex Yang closed HARMONY-1498.
--------------------------------


Verified by Leo.

> [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