[
https://issues.apache.org/jira/browse/HADOOP-20088?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18144761#comment-18144761
]
ASF GitHub Bot commented on HADOOP-20088:
-----------------------------------------
joseluisll opened a new pull request, #8995:
URL: https://github.com/apache/hadoop/pull/8995
### Description of PR
JIRA: [HADOOP-20088](https://issues.apache.org/jira/browse/HADOOP-20088)
This PR fixes by code 10 of the 19 SpotBugs warnings that the nightly qbt
builds (JDK 17 and JDK 21) report in `hadoop-tools/hadoop-distcp`. It is the
code half of the solution; the other half (narrow module-level exclusions for
the 9 warnings whose behaviour is intended) is in
[HADOOP-20017](https://issues.apache.org/jira/browse/HADOOP-20017) / PR #8818,
following the review feedback there.
| # | Class | Warning | Resolution |
|---|---|---|---|
| 1 | `SimpleCopyListing` | SS_SHOULD_BE_STATIC `maxRetries` | `private
static final int MAX_RETRIES = 3` |
| 2 | `DiffInfo` | CT_CONSTRUCTOR_THROW `<init>` | package-private class
made `final` |
| 3 | `DynamicInputChunk` | CT_CONSTRUCTOR_THROW `<init>` | package-private
class made `final` |
| 4 | `DynamicInputChunkContext` | CT_CONSTRUCTOR_THROW `<init>` |
package-private class made `final` |
| 5 | `CopyListingFileStatus` | EI_EXPOSE_REP2 `setAclEntries` | copies the
list, keeping null as null |
| 6 | `CopyListingFileStatus` | EI_EXPOSE_REP2 `setXAttrs` | copies into a
`LinkedHashMap`, keeping null as null and the iteration order |
| 7 | `DistCpContext` | EI_EXPOSE_REP2 `setSourcePaths` | copies the list,
keeping null as null |
| 8 | `DistCpContext` | EI_EXPOSE_REP `getSourcePaths` | returns an
unmodifiable view, or null |
| 9 | `DistCpOptions$Builder` | EI_EXPOSE_REP2 `<init>` | copies the source
path list. `DistCpOptions` is documented as immutable, and `getSourcePaths()`
already returns an unmodifiable copy |
| 10 | `DistCpOptionSwitch` | EI_EXPOSE_REP `getOption` | returns a clone of
the enum's shared, JVM-wide CLI `Option`. The only caller is `OptionsParser`,
which just adds it to `Options` |
No public method signature changes. There are two small behaviour changes
for callers that kept and later changed a collection they passed in. Changes
made to the list after `new DistCpOptions.Builder(list, target)` are no longer
seen, which matches the documented immutability of `DistCpOptions`. Changing
the list returned by `DistCpContext.getSourcePaths()` now throws
`UnsupportedOperationException`; when the paths came from `DistCpOptions` it
already did. Nothing in the repository depends on either behaviour.
Note: the Yetus spotbugs vote on the patch column will report the 9 warnings
excluded in #8818 as unchanged until that PR merges. With both PRs applied the
module reports 0 warnings.
### How was this patch tested?
- SpotBugs on `hadoop-distcp` (`mvn -pl hadoop-tools/hadoop-distcp
spotbugs:spotbugs` / `spotbugs:check`):
- before: **21** BugInstances on trunk.
- with this patch alone: the 10 warnings above are fixed, and the 9
remaining ones are the intended-behaviour warnings excluded in #8818.
- with this patch plus #8818: **0** (`BugInstance size is 0`,
`spotbugs:check` passes).
- Checkstyle (`checkstyle:checkstyle`): no new violations.
- New unit tests cover the behaviour changes. They all fail against the
pre-fix code and pass with it:
- `TestCopyListingFileStatus#testAclEntriesAndXAttrsAreCopied`
- `TestDistCpOptions#testBuilderCopiesSourcePaths`
- `TestDistCpOptions#testContextSourcePaths`
- `TestDistCpOptions#testOptionSwitchReturnsCopyOfOption`
- The full `hadoop-distcp` unit test suite passes locally (Maven 3.9.15, JDK
21), with 0 failures and 0 errors. The 2 skips are the large-file tests in
`TestHDFSContractDistCp`, which are skipped by default.
- The same code and tests ran on Yetus precommit (JDK 17 and 21) as part of
PR #8818: `+1` for test4tests, compile, javac, checkstyle, javadoc, mvnsite,
shadedclient and the hadoop-distcp unit tests (401 run, 0 failures, 0 errors).
### For code changes:
- [x] Does the title of this PR start with the corresponding JIRA issue id
(e.g. 'HADOOP-17799. Your PR title ...')?
- [ ] Object storage: Have the integration tests been executed and the
endpoint
declared according to the connector-specific documentation? *Not
applicable: no object store connector changes.*
- [x] If adding new dependencies to the code, are these dependencies
licensed in a way that is compatible for inclusion under [ASF
2.0](http://www.apache.org/legal/resolved.html#category-a)? *No new
dependencies.*
- [x] If applicable, have you updated the `LICENSE`, `LICENSE-binary`,
`NOTICE-binary` files? *Not applicable.*
### AI Tooling
If an AI tool was used:
- [x] The PR includes the phrase "Contains content generated by Claude Code"
where <tool> is the name of the AI tool used.
- [x] My use of AI contributions follows the ASF legal policy
https://www.apache.org/legal/generative-tooling.html
Contains content generated by Claude Code.
> Defensive copies and immutability fixes for hadoop-distcp SpotBugs warnings
> ---------------------------------------------------------------------------
>
> Key: HADOOP-20088
> URL: https://issues.apache.org/jira/browse/HADOOP-20088
> Project: Hadoop Common
> Issue Type: Bug
> Components: tools/distcp
> Reporter: Jose Luis López
> Priority: Minor
>
> The nightly trunk build (qbt) reports 19 SpotBugs warning(s) in
> hadoop-tools/hadoop-distcp. This issue tracks fixing 10 of them by code
> changes (defensive copies, unmodifiable views and related small behaviour
> changes), with unit tests:
> # SimpleCopyListing, SS_SHOULD_BE_STATIC on maxRetries: private static final
> int MAX_RETRIES
> # DiffInfo, CT_CONSTRUCTOR_THROW: package-private class made final
> # DynamicInputChunk, CT_CONSTRUCTOR_THROW: package-private class made final
> # DynamicInputChunkContext, CT_CONSTRUCTOR_THROW: package-private class made
> final
> # CopyListingFileStatus, EI_EXPOSE_REP2 on setAclEntries: copies the list,
> keeping null as null
> # CopyListingFileStatus, EI_EXPOSE_REP2 on setXAttrs: copies into a
> LinkedHashMap, keeping null as null and the iteration order
> # DistCpContext, EI_EXPOSE_REP2 on setSourcePaths: copies the list, keeping
> null as null
> # DistCpContext, EI_EXPOSE_REP on getSourcePaths: returns an unmodifiable
> view, or null
> # DistCpOptions$Builder, EI_EXPOSE_REP2 on <init>: copies the source path
> list (DistCpOptions is documented as immutable)
> # DistCpOptionSwitch, EI_EXPOSE_REP on getOption: returns a clone of the
> enum's shared CLI Option
> No public method signature changes.
> The remaining 9 warnings, where the current behaviour is intended, are
> handled by narrow module-level SpotBugs exclusions tracked in HADOOP-20017.
> Contains content generated by Claude Code.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]