Skip to content

Commit

Permalink
refactor: change data type for observedVersion
Browse files Browse the repository at this point in the history
  • Loading branch information
guqing committed Jan 25, 2024
1 parent 57dfc52 commit e208e15
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
Expand Up @@ -159,7 +159,7 @@ public static class PostStatus {

private Instant lastModifyTime;

private long observedVersion;
private Long observedVersion;

@JsonIgnore
public ConditionList getConditionsOrDefault() {
Expand Down
Expand Up @@ -154,7 +154,8 @@ public void onApplicationEvent(@NonNull ApplicationContextInitializedEvent event
var version = post.getMetadata().getVersion();
var observedVersion = post.getStatusOrDefault().getObservedVersion();
// do not care about the false case so return null to avoid indexing
return observedVersion >= version ? BooleanUtils.TRUE : null;
return (observedVersion != null && observedVersion >= version)
? BooleanUtils.TRUE : null;
})));
});
schemeManager.register(Category.class, indexSpecs -> {
Expand Down
Expand Up @@ -358,7 +358,8 @@ private String expectListResultJson() {
"apiVersion": "content.halo.run/v1alpha1",
"kind": "Post",
"metadata": {
"name": "fake-post"
"name": "fake-post",
"version": 1
}
},
"stats": {
Expand Down Expand Up @@ -403,7 +404,8 @@ private String expectListResultJson() {
"apiVersion": "content.halo.run/v1alpha1",
"kind": "Post",
"metadata": {
"name": "fake-post"
"name": "fake-post",
"version": 1
}
},
"stats": {
Expand Down Expand Up @@ -447,7 +449,8 @@ private String expectListResultJson() {
"apiVersion": "content.halo.run/v1alpha1",
"kind": "Post",
"metadata": {
"name": "fake-post"
"name": "fake-post",
"version": 1
}
},
"stats": {
Expand Down

0 comments on commit e208e15

Please sign in to comment.