diff --git a/Integration/org.egovframe.rte.itl.webservice/src/main/java/org/egovframe/rte/itl/webservice/service/impl/MessageConverterImpl.java b/Integration/org.egovframe.rte.itl.webservice/src/main/java/org/egovframe/rte/itl/webservice/service/impl/MessageConverterImpl.java index 53a053d4..2731e340 100755 --- a/Integration/org.egovframe.rte.itl.webservice/src/main/java/org/egovframe/rte/itl/webservice/service/impl/MessageConverterImpl.java +++ b/Integration/org.egovframe.rte.itl.webservice/src/main/java/org/egovframe/rte/itl/webservice/service/impl/MessageConverterImpl.java @@ -75,6 +75,11 @@ public Object convertToValueObject(Object source, Type type) throws ClassNotFoun return source; } else if (type instanceof ListType) { LOGGER.debug("### MessageConverterImpl convertToValueObject() : Type is a List Type"); + // 메시지 body에서 List 필드가 생략되면 source가 null로 전달된다. + // 타입 체계가 null을 유효 값으로 허용하므로, 역참조 전에 null을 그대로 반환한다. + if (source == null) { + return null; + } ListType listType = (ListType) type; Object[] components = ((Collection) source).toArray(); Class arrayClass = classLoader.loadClass(listType); @@ -85,6 +90,11 @@ public Object convertToValueObject(Object source, Type type) throws ClassNotFoun return array; } else if (type instanceof RecordType) { LOGGER.debug("### MessageConverterImpl convertToValueObject() : Type is a Record(Map) Type"); + // 메시지 body에서 Record 필드가 생략되면 source가 null로 전달된다. + // 타입 체계가 null을 유효 값으로 허용하므로, 역참조 전에 null을 그대로 반환한다. + if (source == null) { + return null; + } RecordType recordType = (RecordType) type; Map map = (Map) source; Class recordClass = classLoader.loadClass(recordType); diff --git a/Integration/org.egovframe.rte.itl.webservice/src/test/java/org/egovframe/rte/itl/webservice/service/impl/MessageConverterImplTest.java b/Integration/org.egovframe.rte.itl.webservice/src/test/java/org/egovframe/rte/itl/webservice/service/impl/MessageConverterImplTest.java index e729208e..78dafd0b 100755 --- a/Integration/org.egovframe.rte.itl.webservice/src/test/java/org/egovframe/rte/itl/webservice/service/impl/MessageConverterImplTest.java +++ b/Integration/org.egovframe.rte.itl.webservice/src/test/java/org/egovframe/rte/itl/webservice/service/impl/MessageConverterImplTest.java @@ -253,6 +253,20 @@ public void testConvertToTypedObject() throws Exception { assertEquals(person.name, personMap.get("name")); } } + + @Test + public void testConvertToValueObjectWithNullListSource() throws Exception { + // 메시지 body에서 List 필드가 생략되면 source가 null로 전달된다. + // null 역참조(NPE) 없이 null을 반환해야 한다. + assertNull(messageConverter.convertToValueObject(null, personListType)); + } + + @Test + public void testConvertToValueObjectWithNullRecordSource() throws Exception { + // 메시지 body에서 Record 필드가 생략되면 source가 null로 전달된다. + // null 역참조(NPE) 없이 null을 반환해야 한다. + assertNull(messageConverter.convertToValueObject(null, recordType)); + } } class ValueObject {