HDDS-16248. Refactor PutBucketLifecycleConfigurationUnmarshaller to extend MessageUnmarshaller - #11075
HDDS-16248. Refactor PutBucketLifecycleConfigurationUnmarshaller to extend MessageUnmarshaller#11075ChenSammi wants to merge 1 commit into
Conversation
…xtend MessageUnmarshaller
There was a problem hiding this comment.
Pull request overview
This pull request refactors the S3 Gateway’s lifecycle configuration XML parsing to reuse the shared MessageUnmarshaller infrastructure, specifically to ensure parsing uses XMLUtils.newSecureSAXParserFactory() for secure SAX configuration.
Changes:
- Refactored
PutBucketLifecycleConfigurationUnmarshallerto extendMessageUnmarshaller<S3LifecycleConfiguration>instead of implementingMessageBodyReaderdirectly. - Simplified
BucketLifecycleHandlerto invoke the unmarshaller via the new convenience methodreadFrom(InputStream).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/PutBucketLifecycleConfigurationUnmarshaller.java | Replaced custom JAXB/SAX setup with inheritance from MessageUnmarshaller to leverage secure SAX factory and shared namespace handling. |
| hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/BucketLifecycleHandler.java | Updated lifecycle PUT path to use the unmarshaller’s simpler readFrom(body) entrypoint. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
|
||
| private final JAXBContext context; | ||
| private final XMLReader xmlReader; | ||
| extends MessageUnmarshaller<S3LifecycleConfiguration> { |
There was a problem hiding this comment.
nit: add a TestPutBucketLifecycleConfigurationUnmarshaller (with-/without-namespace round-trip) to match MultiDeleteRequestUnmarshaller and CompleteMultipartUploadRequestUnmarshaller; today it's only covered indirectly via TestS3LifecycleConfigurationPut. Also keep "namespace" in the class javadoc — the base still filters on S3_XML_NAMESPACE.
What changes were proposed in this pull request?
Refactor PutBucketLifecycleConfigurationUnmarshaller to extend MessageUnmarshaller, to leverage XMLUtils.newSecureSAXParserFactory().
What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-16248
How was this patch tested?
existing unit tests