You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "DIscord010 (GitHub)" <gi...@apache.org> on 2020/05/04 10:04:11 UTC

[GitHub] [dubbo] DIscord010 opened pull request #6100: [Dubbo-5939] fix ClassCastException when PojoUtils realize JsonObject to Map

## What is the purpose of the change

fix #5939 

## Brief changelog

Add Key type check. 

## Verifying this change
`    
    @Test
    public void testJsonObjectToMap() throws Exception {
        Method method = PojoUtilsTest.class.getMethod("setMap", Map.class);
        assertNotNull(method);
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("1", "test");
        @SuppressWarnings("unchecked")
        Map<Integer, Object> value = (Map<Integer, Object>)PojoUtils.realize(jsonObject,
                method.getParameterTypes()[0],
                method.getGenericParameterTypes()[0]);
        method.invoke(new PojoUtilsTest(), value);
        assertEquals("test", value.get(1));
    }

    public void setMap(Map<Integer, Object> map) {}
`


[ Full content available at: https://github.com/apache/dubbo/pull/6100 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org