Skip to content

Fix a few correctness bugs flagged by SpotBugs (static analysis)#161

Open
vejtom wants to merge 2 commits into
iipc:masterfrom
vejtom:fix-spotbugs-correctness
Open

Fix a few correctness bugs flagged by SpotBugs (static analysis)#161
vejtom wants to merge 2 commits into
iipc:masterfrom
vejtom:fix-spotbugs-correctness

Conversation

@vejtom

@vejtom vejtom commented Jun 18, 2026

Copy link
Copy Markdown

Ran SpotBugs over the code and a handful of CORRECTNESS warnings looked like real bugs. Small fixes below:

  • StreamCopy: the 3-arg copyLength() called itself instead of the 4-arg overload, so it recurses forever. Now it delegates to the 4-arg version.
  • ByteOp.drawHex: rows was Math.ceil(length / bytesPerRow), but that's integer division so ceil never rounds up. Cast to double first.
  • MetaData(...): putChild() was called on parentMetaData even when it's null, which throws an NPE. Guarded the call.
  • GZIPDecoder: lookahead[2] was compared to GZIP_MAGIC_TWO (0x8b) without masking, so a signed byte never matches. Added & 0xff — the same file already does this a few lines down.

Build passes locally.

@ato ato left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The other changes look good to me.

Comment thread src/main/java/org/archive/resource/MetaData.java Outdated
bobhenl

This comment was marked as spam.

@vejtom

vejtom commented Jun 19, 2026

Copy link
Copy Markdown
Author

Thank you @ato, should be OK now!

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