Skip to content

Commit

Permalink
Merge pull request #163 from remondis-it/fix-mappingex-npe
Browse files Browse the repository at this point in the history
Fixing NPE in building mapping exception detail text.
  • Loading branch information
schuettec authored Jul 31, 2024
2 parents ed00e9c + 8d2f811 commit f74ce7c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.remondis</groupId>
<artifactId>remap</artifactId>
<version>4.3.6</version>
<version>4.3.7</version>
<packaging>jar</packaging>
<name>ReMap</name>
<description>A declarative mapping library for converting objects field by field.</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ private void init() {
}
}

private boolean isEmpty() {
boolean isEmpty() {
return stack.isEmpty();
}

Expand Down
20 changes: 12 additions & 8 deletions src/main/java/com/remondis/remap/MappingException.java
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,14 @@ static MappingException incompatibleCollectionMapping(PropertyDescriptor sourceP
GenericParameterContext rootSrcCtx = new GenericParameterContext(sourceProperty.getReadMethod());
GenericParameterContext rootDestCtx = new GenericParameterContext(destinationProperty.getReadMethod());
StringBuilder builder = new StringBuilder("Incompatible nested collections found mapping\n\t");
String rootSourceGenericCtx = rootSrcCtx.isEmpty() ? "unknown" : rootSrcCtx.get()
.toString();
String rootDestGenericCtx = rootDestCtx.isEmpty() ? "unknown" : rootDestCtx.get()
.toString();
String sourceGenericCtx = sourceCtx.isEmpty() ? "unknown" : sourceCtx.get()
.toString();
String destGenericCtx = destCtx.isEmpty() ? "unknown" : destCtx.get()
.toString();
builder.append(asString(sourceProperty))
.append(" to ~>\n\t")
.append(asString(destinationProperty))
Expand All @@ -165,18 +173,14 @@ static MappingException incompatibleCollectionMapping(PropertyDescriptor sourceP
.append("\nType nesting is\n\t")
.append("-> in source type: ")
.append("\n\t")
.append(rootSrcCtx.get()
.toString())
.append(rootSourceGenericCtx)
.append("\n\t-> in destination type: ")
.append("\n\t")
.append(rootDestCtx.get()
.toString())
.append(rootDestGenericCtx)
.append("\n\tcannot map \n\t")
.append(sourceCtx.get()
.toString())
.append(sourceGenericCtx)
.append("\n\tto\n\t")
.append(destCtx.get()
.toString());
.append(destGenericCtx);
return new MappingException(builder.toString());
}

Expand Down

0 comments on commit f74ce7c

Please sign in to comment.