Closed
Description
import org.springframework.data.domain.Limit;
Limit limited = Limit.of(5);
Limit unlimited = Limit.unlimited();
limited.equals(unlimited);
The above code throws an IllegalStateException with message "Unlimited does not define 'max'. Please check 'isLimited' before attempting to read 'max'". It is caused by the incomplete equals method where this case is not handled (this: limited, that: unlimited).
Fix:
if (this.isUnlimited() && that.isUnlimited()) {
return true;
}
must be replaced with
if (that.isUnlimited()) {
return false;
}
(this.isUnlimited() is always false anyway)
u.i.: I found this in a unit test where multiple queries were mocked and the Query::equals called Limit::equals in the background, causing some tests fail.