HADOOP-19993. Fix SpotBugs SE_BAD_FIELD in McpHttpServlet - #8753
jojochuang wants to merge 1 commit into
Conversation
Mark MCP servlet dependency fields transient so trunk hadoop-common passes SpotBugs strict precheck (YARN-11977 follow-up). Co-authored-by: Cursor <cursoragent@cursor.com>
|
💔 -1 overall
This message was automatically generated. |
|
Thanks for picking this up. I reproduced the warning locally and I think the patch is right in approach but over-applied by one field: as written it swaps Three runs on a clean branch off trunk at 1. Baseline, unmodified trunk — 2. This PR's diff (both fields
3. Only Clean. ( The reason for the asymmetry: Jackson's So the suggestion is just to drop the private final ObjectMapper objectMapper;
private final transient McpRequestHandler requestHandler;That also matches what other hadoop-common servlets do — Happy to be wrong if your run shows something different — worth confirming, since the Jenkins run on this PR only checks that the patch is clean, not that the module reaches zero. |
joseluisll
left a comment
There was a problem hiding this comment.
@jojochuang SpotBugs on hadoop-common, with this PR as-is and with the suggestion below applied (WSL2 Ubuntu 24.04, OpenJDK 17.0.20, Maven 3.9.16, spotbugs-maven-plugin 4.9.7.0, 2666 classes analyzed in both runs):
./mvnw -pl hadoop-common-project/hadoop-common -am -DskipTests clean test-compile spotbugs:spotbugs
McpHttpServlet fields |
total_bugs |
|---|---|
both transient (this PR) |
1: SE_TRANSIENT_FIELD_NOT_RESTORED on objectMapper |
only requestHandler transient |
0 |
|
|
||
| private final ObjectMapper objectMapper; | ||
| private final McpRequestHandler requestHandler; | ||
| private final transient ObjectMapper objectMapper; |
There was a problem hiding this comment.
| private final transient ObjectMapper objectMapper; | |
| private final ObjectMapper objectMapper; |
ObjectMapper is Serializable, so it never tripped SE_BAD_FIELD; the transient here is what raises the SE_TRANSIENT_FIELD_NOT_RESTORED in the Yetus run.
Summary
objectMapperandrequestHandlerinMcpHttpServletastransientso SpotBugs no longer reportsSE_BAD_FIELDon trunkhadoop-common.hadoop-common(e.g. HDFS-17981 / HDFS-17981. Make the bind address for HDFS NFS Gateway configurable #8744).Context
Follow-up to YARN-11977 (MCP HTTP server in hadoop-common). Trunk currently reports one extant SpotBugs warning:
McpHttpServletdefines non-transient non-serializable instance fieldrequestHandler.HttpServlet implements
Serializable, but these servlet instances are not serialized in normal deployment;transientmatches common servlet practice.Test plan
./mvnw -pl hadoop-common-project/hadoop-common -DskipTests test-compile spotbugs:spotbugshttps://issues.apache.org/jira/browse/HADOOP-19993
Made with Cursor