Skip to content

Commit 2f03bad

Browse files
committed
Call setter only after object has been populated
This closes #266
1 parent 43aa6f4 commit 2f03bad

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

modello-plugins/modello-plugin-xpp3/src/main/java/org/codehaus/modello/plugin/xpp3/Xpp3ReaderGenerator.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,7 @@ private void processField( ModelField field, XmlFieldMetadata xmlFieldMetadata,
870870
if ( locationTracker != null )
871871
{
872872
sc.add( locationTracker.getName() + " " + LOCATION_VAR + "s;" );
873-
writeNewSetLocation( field, objectName, LOCATION_VAR + "s", sc );
873+
writeNewLocation( LOCATION_VAR + "s", sc );
874874
}
875875

876876
if ( xmlAssociationMetadata.isMapExplode() )
@@ -954,7 +954,7 @@ private void processField( ModelField field, XmlFieldMetadata xmlFieldMetadata,
954954
sc.unindent();
955955
sc.add( "}" );
956956
}
957-
957+
writeSetLocation( field, objectName, LOCATION_VAR + "s", sc );
958958
sc.unindent();
959959
sc.add( "}" );
960960
}
@@ -1659,6 +1659,11 @@ private String buildNewLocation( String source )
16591659
+ ( ( sourceTracker != null ) ? ", " + source : "" ) + " )";
16601660
}
16611661

1662+
private void writeSetLocation( ModelField field, String objectName, String trackerVariable, JSourceCode sc )
1663+
{
1664+
writeSetLocation( "\"" + field.getName() + "\"", objectName, trackerVariable, sc );
1665+
}
1666+
16621667
private void writeSetLocation( String key, String objectName, String trackerVariable, JSourceCode sc )
16631668
{
16641669
if ( locationTracker == null )

0 commit comments

Comments
 (0)