aucd29 / cloning

Automatically exported from code.google.com/p/cloning
Other
0 stars 0 forks source link

NullPointerReference by call shallowClone() #7

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create map with array as value.
2. Call shallowClone() method.
3.

What is the expected output? What do you see instead?
Expected - copy, see -  NullPointerException

What version of the product are you using? On what operating system?
1.7.9
1.8.0

Please provide any additional information below.
Ver 179 in Cloner line 422 check for null is needed.
clones.put(o, newInstance); -> if (clones!=null)clones.put(o, newInstance);

Original issue reported on code.google.com by om.regis...@gmail.com on 8 May 2012 at 7:58

GoogleCodeExporter commented 9 years ago
Can you please provide an example? I tried but this works ok:

HashMap<String, byte[]> m = new HashMap<String, byte[]>();
        m.put("test", new byte[] { 1, 2, 3 });
        HashMap<String, byte[]> clone = cloner.deepClone(m);
        byte[] a = clone.get("test");
        assertEquals(1, a[0]);
        assertEquals(2, a[1]);
        assertEquals(3, a[2]);

Original comment by kostas.k...@googlemail.com on 8 May 2012 at 10:20

GoogleCodeExporter commented 9 years ago
    HashMap<Object, Object> source = new HashMap<Object, Object>();
    source.put("string", new String("string"));
    source.put("array", new Integer[]{1,2,3});  
    HashMap<Object, Object> dest  = cloner.shallowClone(source);

Original comment by om.regis...@gmail.com on 8 May 2012 at 10:39

GoogleCodeExporter commented 9 years ago
fixed in 1.8.1

Original comment by kostas.k...@googlemail.com on 9 May 2012 at 10:28

GoogleCodeExporter commented 9 years ago
Thanks.

Original comment by om.regis...@gmail.com on 10 May 2012 at 8:00