Skip to content

Fix Manifest/Resource equals/hashCode and add errorprone#77

Merged
ctubbsii merged 4 commits intoapache:mainfrom
ctubbsii:fix-equals-hash-code-add-errorprone
Feb 24, 2026
Merged

Fix Manifest/Resource equals/hashCode and add errorprone#77
ctubbsii merged 4 commits intoapache:mainfrom
ctubbsii:fix-equals-hash-code-add-errorprone

Conversation

@ctubbsii
Copy link
Member

  • Add errorprone CI checks to GitHub Actions and compat checks for Accumulo 4.0
  • Update code to fix items caught by errorprone
  • Rename manifests field to monitoredManifests, just to make it more obvious that it is tracking the manifests currently being monitored
  • Fix equals and hashCode methods for Manifest and Resource, to account for comment and algorithm fields, respectively
  • Add test for deduplication of resources in a json

* Add errorprone CI checks to GitHub Actions and compat checks for
  Accumulo 4.0
* Update code to fix items caught by errorprone
* Rename manifests field to monitoredManifests, just to make it more
  obvious that it is tracking the manifests currently being monitored
* Fix equals and hashCode methods for Manifest and Resource, to account
  for comment and algorithm fields, respectively
* Add test for deduplication of resources in a json
@ctubbsii ctubbsii self-assigned this Feb 20, 2026
@ctubbsii
Copy link
Member Author

ctubbsii commented Feb 20, 2026

I expect the 4.0.0-SNAPSHOT test to fail for now, because the latest SNAPSHOT hasn't yet been built, but it should work locally if you build and install 4.0.0-SNAPSHOT to your local maven repository.

EDIT: reran failed check after publishing latest 4.0 snapshot and it passed

json.append("{'location': 'file:/home/user/ClassLoaderTestA/" + i + ".jar'").append(COMMA);
json.append("'algorithm': 'MOCK',").append("'checksum': '" + i + "'}");
var n = i;
if (withResourceCount == 10) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When reading the new test testDeserializationWithDeduplication() it was confusing at first how it was duplicating. Then saw that 10 was a special value in this code.

Copy link
Member Author

@ctubbsii ctubbsii Feb 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The special value was the simplest implementation I could think of that required the least amount of new test code, but I tried to add a comment in both places: where the value is used and where it is checked. It looks like I forgot to keep the comment in the place where it is used.

Manifest other = (Manifest) obj;
return monitorIntervalSeconds == other.monitorIntervalSeconds
&& Objects.equals(resources, other.resources);
return obj instanceof Manifest ? Objects.equals(toJson(), ((Manifest) obj).toJson()) : false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its not a problem to call Object.equals here, but does not seem needed since the json values will not be null.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I thought about simplifying this but I liked the way it looks, so I didn't bother to change it. I don't feel strongly either way.

LOG.trace("Skipped resource {} while another process or thread is downloading it",
resource.getLocation());
waitingOnOtherDownloadsCount++;
continue;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why remove this? It will cause this process to wait instead of immediately moving on to the next resource.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The continue was for the for loop, which ends immediately after the continue, not the do-while loop that has the wait. So, errorprone correctly flagged it as redundant.

@ctubbsii ctubbsii merged commit 584e5bd into apache:main Feb 24, 2026
9 of 10 checks passed
@ctubbsii ctubbsii deleted the fix-equals-hash-code-add-errorprone branch February 24, 2026 20:07
@ctubbsii ctubbsii added this to the 1.0.0 milestone Mar 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants