smengcl opened a new pull request, #10710:
URL: https://github.com/apache/ozone/pull/10710
Generated-by: Claude Code (Opus 4.8)
## What changes were proposed in this pull request?
The `hadoop-ozone/httpfsgateway` module was the only remaining consumer of
`com.googlecode.json-simple:json-simple` (1.1.1), a library that has been
unmaintained since 2012. Jackson (`jackson-databind`) is already a compile
dependency of the module, so json-simple was redundant and carried needless
maintenance and supply chain risk.
This PR migrates all JSON serialization in httpfsgateway from json-simple to
Jackson, then removes the dependency:
* `JSONMapProvider` now 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,
matching the previous behavior.
* `JSONProvider`, whose only purpose was serializing json-simple
`JSONStreamAware` entities, is removed. JAX-RS providers are registered by
Jersey package scanning via `jersey.config.server.provider.packages`, so
deleting the class is sufficient to unregister 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 the `dependencyManagement` entry are removed from the root pom. The
`com.googlecode.json-simple:json-simple` entries in the distribution
`bin/LICENSE.txt` and the generated `jar-report.txt` inventory are removed
accordingly.
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
(which parse by key) are unaffected by. The `replaceAll("\\\\", "")` call in
`FSCreateSnapshot`, originally there to undo json-simple's forward slash
escaping (`\/`), becomes a harmless no-op since Jackson does not escape slashes.
## What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-15808
## How was this patch tested?
Two focused unit tests were added to the module (which previously had almost
no coverage for these paths):
* `TestInstrumentationSerialization` verifies the `@JsonValue` serialization
of `Timer`, `VariableHolder`, and `Sampler` produces the expected JSON keys and
values.
* `TestJSONMapProvider` verifies the provider emits compact JSON followed by
a trailing newline and does not close the underlying stream.
Verified locally: the module compiles, all module unit tests pass (2
existing + 5 new), `checkstyle.sh` is clean, and `rat.sh` reports 0 unknown
licenses.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]