[ 
https://issues.apache.org/jira/browse/HDDS-15808?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Siyao Meng reassigned HDDS-15808:
---------------------------------

    Assignee: Siyao Meng

> Replace json-simple with Jackson in httpfsgateway
> -------------------------------------------------
>
>                 Key: HDDS-15808
>                 URL: https://issues.apache.org/jira/browse/HDDS-15808
>             Project: Apache Ozone
>          Issue Type: Improvement
>          Components: HttpFS GateWay
>            Reporter: Siyao Meng
>            Assignee: Siyao Meng
>            Priority: Major
>              Labels: pull-request-available
>
> h3. Problem
> The {{hadoop-ozone/httpfsgateway}} module is the only remaining consumer of 
> {{com.googlecode.json-simple:json-simple}} (1.1.1), a library unmaintained 
> since 2012. Jackson ({{jackson-databind}}) is already a compile dependency of 
> the module, so json-simple is redundant.
> h3. Approach
> Migrate all JSON serialization in httpfsgateway from json-simple to Jackson, 
> then drop the dependency:
> * {{JSONMapProvider}} serializes the response {{Map}} with a shared 
> {{ObjectMapper}}. {{AUTO_CLOSE_TARGET}} is disabled so the underlying 
> response stream stays open for the trailing newline and container managed 
> close.
> * {{JSONProvider}} (which only served to serialize json-simple 
> {{JSONStreamAware}} entities) is removed. Providers are registered by Jersey 
> package scanning via {{jersey.config.server.provider.packages}}, so deleting 
> the class unregisters it.
> * In {{InstrumentationService}}, the {{Timer}}, {{VariableHolder}}, and 
> {{Sampler}} snapshot types no longer implement 
> {{JSONAware}}/{{JSONStreamAware}}. Their {{getJSON()}} methods return a 
> {{LinkedHashMap}} annotated with {{@JsonValue}}, so Jackson serializes each 
> object as that map and produces the same JSON.
> * {{FSOperations}} and {{HttpFSServer}} use {{Map}}/{{List}} 
> ({{LinkedHashMap}}/{{ArrayList}}) in place of {{JSONObject}}/{{JSONArray}}, 
> and reuse the module local {{JsonUtil.toJsonString}} helper.
> * The dependency is removed from the module pom, and the version property 
> plus dependencyManagement entry are removed from the root pom. The 
> json-simple entries in the distribution {{bin/LICENSE.txt}} and the generated 
> {{jar-report.txt}} inventory are removed accordingly.
> h3. Compatibility
> The wire format is preserved. Both libraries emit standard JSON, 
> {{AtomicLong}} serializes as a bare number in both, and switching from 
> {{HashMap}} to {{LinkedHashMap}} only makes key order deterministic, which 
> WebHDFS clients parsing by key are unaffected by. The {{replaceAll}} call in 
> {{FSCreateSnapshot}}, originally undoing json-simple forward slash escaping, 
> becomes a harmless no-op since Jackson does not escape slashes.
> h3. Testing
> Added two focused unit tests in the module:
> * {{TestInstrumentationSerialization}} verifies the {{@JsonValue}} 
> serialization of {{Timer}}, {{VariableHolder}}, and {{Sampler}}.
> * {{TestJSONMapProvider}} verifies the provider emits compact JSON followed 
> by a trailing newline and does not close the underlying stream.
> Module build, checkstyle, and rat pass; all module unit tests pass.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to