hapifhir / hapi-hl7v2

277 stars 138 forks source link

Wrong deep copy target when setting data for Type class instance #129

Closed paulolaup closed 1 month ago

paulolaup commented 1 month ago

Issue:

When attempting to set the data property of an instance of the ca.uhn.hl7.v2.model.Type class the supplied value of the same type gets its values overridden by a conditional deep copy of the existing property value.

public void setData(Type data) throws DataTypeException {
        if (this.data != null && (!(this.data instanceof Primitive) || ((Primitive)this.data).getValue() != null)) {
            DeepCopy.copy(this.data, data);
        }

        this.data = data;
}

Is this intended behavior?

Solution (probably):

Switch values for parameters from and to of DeepCopy.copy method call in Type.setData method.

paulolaup commented 1 month ago

According to the method documentation, this is intended behaviour.