Skip to content

Commit

Permalink
DUBBO-627 fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
kimi committed Jan 9, 2013
1 parent e8970a0 commit e3f8af7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ private static void serializeInternal(JavaBeanDescriptor descriptor, Object obj,
for (int i = 0; i < len; i++) {
Object item = Array.get(obj, i);
if (item == null) {
descriptor.setProperty(i++, null);
descriptor.setProperty(i, null);
} else {
JavaBeanDescriptor itemDescriptor = createDescriptorIfAbsent(item, accessor, cache);
descriptor.setProperty(i, itemDescriptor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,19 @@ public void testSerialize_Array() throws Exception {
((JavaBeanDescriptor) descriptor.getProperty(i)).getPrimitiveProperty());
}

Integer[] integers = new Integer[]{1, 2, 3, 4, null, null, null};
descriptor = JavaBeanSerializeUtil.serialize(integers, JavaBeanAccessor.METHOD);
Assert.assertTrue(descriptor.isArrayType());
Assert.assertEquals(Integer.class.getName(), descriptor.getClassName());
Assert.assertEquals(integers.length, descriptor.propertySize());
for(int i = 0; i < integers.length; i++) {
if (integers[i] == null) {
Assert.assertTrue(integers[i] == descriptor.getProperty(i));
} else {
Assert.assertEquals(integers[i], ((JavaBeanDescriptor)descriptor.getProperty(i)).getPrimitiveProperty());
}
}

int[][] second = {{1, 2}, {3, 4}};
descriptor = JavaBeanSerializeUtil.serialize(second, JavaBeanAccessor.METHOD);
Assert.assertTrue(descriptor.isArrayType());
Expand Down

0 comments on commit e3f8af7

Please sign in to comment.