Skip to content

refactor(admin): drop commons-io by replacing two IOUtils.copy call sites (#7607) - #7887

Merged
Aias00 merged 1 commit into
apache:masterfrom
konlue:refactor/admin-drop-commons-io
Oct 21, 2026
Merged

Aias00 merged 1 commit into
apache:masterfrom
konlue:refactor/admin-drop-commons-io

Conversation

@konlue

@konlue konlue commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Following up on my comment from Oct 14 — proceeding with the narrowed scope proposed there (commons-io only), since the issue remains unassigned and unclaimed. Happy to adjust if you'd rather keep commons-io.

Fixes #7607.

Summary

The issue lists both commons-io and commons-collections4 for removal from shenyu-admin. On master, commons-collections4 is imported by ~65 files (not removable now), so this PR — as proposed in the comment above — only removes commons-io, whose entire admin usage is two IOUtils.copy calls.

Modifications

  • Replace both IOUtils.copy(...) call sites with org.springframework.util.StreamUtils.copy(...) (ClusterForwardFilter, SandboxServiceImpl). Identical semantics: buffered copy with both streams left open for the caller.
  • Remove the commons-io dependency from shenyu-admin/pom.xml only. The ${commons-io.version} property stays — shenyu-plugin-cryptor and shenyu-protocol-tcp still reference it.

Verifying this change

  • Targeted tests pass (-pl shenyu-admin -am):

    # ClusterForwardFilterTest 4/4 green
    # SandboxServiceImplTest 2/2 green
  • Grep check passes:

    git grep -n "org.apache.commons.io" -- shenyu-admin
    # Returns no hits
  • Checkstyle passes:

    ./mvnw -B -ntp -pl shenyu-admin checkstyle:check
    # clean

@Aias00 Aias00 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review: drop commons-io from shenyu-admin

Straightforward and complete. I verified the important part — that the removed dependency has no remaining callers — rather than assuming it:

  • org.apache.commons.io appears in exactly two files across the whole repository on master (SandboxServiceImpl, ClusterForwardFilter), and both are converted here. So the direct dependency can safely go, and pr_build confirms it compiles.
  • StreamUtils.copy(InputStream, OutputStream) has the same contract as IOUtils.copy: it returns the byte count, does not close either stream, and does not flush. Both call sites still flush explicitly (response.getOutputStream().flush() / response.flushBuffer()), so the response-writing semantics are unchanged.
  • Removing the version-pinned dependency block does not orphan commons-io.version in the root POM; other modules still use the property.

Non-blocking notes:

  1. StreamUtils.BUFFER_SIZE is 4096 while IOUtils.copy defaults to 8192, so proxied response bodies are now copied in half-size chunks. Irrelevant for admin-sized payloads, but ClusterForwardFilter forwards arbitrary gateway responses — if you ever care, StreamUtils.copy(in, out, 8192) restores the old buffer.
  2. This only removes the direct declaration. commons-io is a very common transitive of test/proxy libraries, so the jar may still land on the admin classpath. If dropping it from the shaded distribution was the goal, confirm with ./mvnw -pl shenyu-admin dependency:tree -Dincludes=commons-io:commons-io before claiming it is gone.

Nothing else to flag — the diff is minimal, imports are cleaned up, and the two conversions preserve behaviour.

@Aias00
Aias00 merged commit cc9a69a into apache:master Oct 21, 2026
55 checks passed
@Aias00 Aias00 added this to the 2.7.2 milestone Nov 13, 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.

refactor(dependencies): remove unused commons-io and commons-collections4 from shenyu-admin

2 participants