Repository navigation
HADOOP-19993. Fix SpotBugs SE_BAD_FIELD in McpHttpServlet - #8753
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. |
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):
Eliminate the "transient" from objectMapper, and thats it.
|
Hi all! First of all sorry to blocking so many PR with this previous change. During the development i realised this "loop" problem and found a solution for this And found some workaround of the problem in WebAppProxyServlet.java Hope this can help. |
…adoop/mcp/McpHttpServlet.java ObjectMapper implements Serializable and does not need to be transient. Remove the modifier to avoid SE_TRANSIENT_FIELD_NOT_RESTORED, while keeping requestHandler transient to fix SE_BAD_FIELD. Co-authored-by: Jose Luis López López <joseluisll@gmail.com>
|
💔 -1 overall
This message was automatically generated. |
|
@jojochuang Thanks for the contribution! Yetus confirms that the existing SpotBugs warning is fixed with no new warnings, and both the existing unit tests and GitHub Actions Build passed. @ayushtkn @joseluisll @K0K0V0K Thanks for the review! |
Summary
requestHandlerinMcpHttpServletastransientto fixSE_BAD_FIELD. KeepobjectMappernon-transient becauseObjectMapperimplementsSerializable, avoidingSE_TRANSIENT_FIELD_NOT_RESTOREDand reducing the SpotBugs warning count to zero.hadoop-common(e.g. HDFS-17981 / HDFS-17981. Make the bind address for HDFS NFS Gateway configurable #8744).Context
JIRA: HADOOP-19993. Fix SpotBugs SE_BAD_FIELD in McpHttpServlet
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