Skip to content

feat(io)!: return the copied count as a long from CopyUtil.copy and bump to 0.8.0-SNAPSHOT - #26

Open
marevol wants to merge 3 commits into
mainfrom
feat/copyutil-long-count
Open

marevol wants to merge 3 commits into
mainfrom
feat/copyutil-long-count

Conversation

@marevol

@marevol marevol commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #25.

Changes

Compatibility

This is a breaking change, hence the minor version bump:

  • Source: code that assigns the result to an int no longer compiles. No caller in the codelibs repositories uses the result (fess, fess-crawler and fess-ds-git call CopyUtil.copy and discard it), so they compile unchanged.
  • Binary: a class compiled against an earlier corelib refers to the int-returning method and fails with NoSuchMethodError at the call site until it is recompiled, even when it ignores the result. Consumers have to be rebuilt against 0.8.0 rather than given the new jar alone.

Verification

  • mvn test: 708 tests pass. The CopyUtilTest assertions now compare against long counts.
  • A one-off harness (not committed, it needs ~2GB of disk) copied 2GB + 12,305 bytes through copy(InputStream, File), copy(File, OutputStream) and copy(File, File). Each returned exactly 2,147,495,953, matching the bytes written.

The next release changes the return type of CopyUtil.copy, which breaks
binary compatibility, so it is a minor version bump.
CopyUtil.copy returned an int, so since #25 a copy larger than
Integer.MAX_VALUE bytes or characters reported Integer.MAX_VALUE instead
of the real count. Every copy method and copyInternal now return a long
with the exact count, and the cap is removed.

BREAKING CHANGE: the return type of every CopyUtil.copy overload and of
the protected copyInternal methods changes from int to long. Code that
assigns the result to an int no longer compiles, and classes compiled
against an earlier corelib fail with NoSuchMethodError at the call site
until they are recompiled, even when they ignore the result.
@marevol marevol self-assigned this Nov 29, 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.

1 participant