Possible bug using @TargetAggregateVersion annotation

Hi all,

I am using latest axon version (2.1.2).

I noticed this strange behaviour while using the annotation @TargetAggregateVersion

to check for version mismatch in Aggregates.

The code is the following.

@TargetAggregateVersion
public Long getVersion() {
return version;
}

The weird thing is that everything works if the version you pass to the command contructor is valid.

With valid i mean a NOT NULL Long value.

If you pass a NULL value then no exception is thrown while i am expecting

to receive the org.axonframework.repository.ConflictingAggregateVersionException.

Is this a bug or a planned behaviour?

Thanks in advance.

Andrea Paternesi.

Hi Andrea,

this is actually intended (and documented) behavior. From the Repository.load() javadoc: “If the expectedVersion is null, no version validation is done.”.
Validation is only done for non-null values.

Cheers,

Allard

Ok thank you very much. I will check for nullity then:)

Andrea.