mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
#485 ArrayCopyWrapper local var possibly not safe
This commit is contained in:
parent
a381396839
commit
9b888847ea
@ -170,7 +170,13 @@ public class PropertyMapping extends ModelElement {
|
||||
}
|
||||
else if ( targetType.isArrayType() && sourceType.isArrayType() && assignment.getType() == DIRECT ) {
|
||||
Type arrayType = ctx.getTypeFactory().getType( Arrays.class );
|
||||
assignment = new ArrayCopyWrapper( assignment, targetPropertyName, arrayType, targetType );
|
||||
assignment = new ArrayCopyWrapper(
|
||||
assignment,
|
||||
targetPropertyName,
|
||||
arrayType,
|
||||
targetType,
|
||||
existingVariableNames
|
||||
);
|
||||
assignment = new NullCheckWrapper( assignment );
|
||||
}
|
||||
else {
|
||||
|
@ -18,11 +18,13 @@
|
||||
*/
|
||||
package org.mapstruct.ap.model.assignment;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.mapstruct.ap.model.common.Type;
|
||||
import org.mapstruct.ap.util.Strings;
|
||||
import static org.mapstruct.ap.util.Strings.decapitalize;
|
||||
import static org.mapstruct.ap.util.Strings.getSaveVariableName;
|
||||
|
||||
@ -38,9 +40,9 @@ public class ArrayCopyWrapper extends AssignmentWrapper {
|
||||
private final Type targetType;
|
||||
|
||||
public ArrayCopyWrapper(Assignment decoratedAssignment, String targetPropertyName, Type arraysType,
|
||||
Type targetType) {
|
||||
Type targetType, Collection<String> existingVariableNames ) {
|
||||
super( decoratedAssignment );
|
||||
this.targetPropertyName = targetPropertyName;
|
||||
this.targetPropertyName = Strings.getSaveVariableName( targetPropertyName, existingVariableNames );
|
||||
this.arraysType = arraysType;
|
||||
this.targetType = targetType;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user