bitflicker64 opened a new pull request, #3459:
URL: https://github.com/apache/hugegraph/pull/3459
## Purpose of the PR
Java 17 cleanups found while scanning `hugegraph-server/hugegraph-core`. The
success paths are unchanged. The try-with-resources hunks also close files on
the error path, and one stream that was never closed.
## Main Changes
- Use `instanceof` pattern variables where a cast followed the check:
`HugeFactory.open`, `IndexLabelBuilder.allStringIndex`,
`HugeVertexProperty.equals`, `HugeCountStep.equals`, `HugeGraphStep.equals`,
`SubGraphTraverser.RingPath.equals`, `CachedBackendStore.QueryId.equals`,
`OffheapCache.Value.asBuffer`, `BackendTable` and `QueryList.close`. The order
of evaluation stays the same: in the `equals` methods `super.equals` still runs
after the type check, and in `BackendTable` `conditionsSize()` is still checked
first. `HugeVertexProperty.equals` no longer needs its
`@SuppressWarnings("unchecked")`.
- Open files in try-with-resources:
- `K8sRegister.getKubeToken` and `getKubeNamespace` already closed the
reader in a `finally`.
- `PdRegister.getKubeToken` and `getNamespace` leaked the reader when the
read failed. Both still swallow the error and return the same value.
- `K8sManager.loadOperatorTemplate` leaked the reader when the read
failed. The template is still set before the reader closes.
- `K8sRegister.initHttpClient` never closed the CA certificate stream; it
is now closed right after the certificate is parsed, still inside the same
`synchronized` method.
- Remove dead code: the private `HugeTableType.ALL_NAME` map was filled in
the static block and never read (`SerialEnum.register` still runs there), and
the private `ConfigUtil.CHARSET` constant had no reader.
No public or protected signature, stored format, config key, log message or
lock changes. The only edge case that differs: if a read and the following
close both fail, the read error now propagates, with the close error suppressed
under it.
## Verifying these changes
- [ ] Trivial rework / code cleanup without any test coverage. (No Need)
- [x] Already covered by existing tests, such as *(please modify tests
here)*.
- [ ] Need tests and can be verified as follows:
- Ran on Linux x86_64, OpenJDK 17.0.20.1, Maven 3.8.7, 2026-11-07, at
`b2618cf0c`:
`mvn -ntp -B test -pl hugegraph-server/hugegraph-test -am -P unit-test
-Deditorconfig.skip=true -Dmaven.javadoc.skip=true`
Result: BUILD SUCCESS, `UnitTestSuite` ran 1426 tests, 0 failures, 0
errors, 8 skipped.
`mvn -ntp -B test -pl hugegraph-server/hugegraph-test -am -P
core-test,memory -Deditorconfig.skip=true -Dmaven.javadoc.skip=true`
Result: BUILD SUCCESS, `CoreTestSuite` ran 1033 tests, 0 failures, 0
errors, 128 skipped.
- These suites reach the changed `equals` methods (for example
`CountStrategyCoreTest`, `CacheTest`), `BackendTable`, `QueryList.close` (paged
index queries) and `OffheapCache` (`CacheTest.OffheapCacheTest`). The
Kubernetes and PD register file reads only run inside a cluster and have no
unit test; on their success path the code is the same.
- `-Deditorconfig.skip=true` is there because master fails the
editorconfig check on `helm/hugegraph/docs/rag.md` (missing final newline), a
file this PR does not touch.
## Does this PR potentially affect the following parts?
- [ ] Dependencies ([add/update
license](https://hugegraph.apache.org/docs/contribution-guidelines/contribute/#321-check-licenses)
info &
[regenerate_known_dependencies.sh](../install-dist/scripts/dependency/regenerate_known_dependencies.sh))
- [ ] Modify configurations
- [ ] The public API
- [ ] Other affects (typed here)
- [x] Nope
## Documentation Status
- [ ] `Doc - TODO`: required documentation is pending; complete it before
merging.
- [ ] `Doc - Done`: documentation is included here or linked below.
- [x] `Doc - No Need`: no user-visible documentation is affected.
--
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]