bitflicker64 opened a new pull request, #3462:
URL: https://github.com/apache/hugegraph/pull/3462
## Purpose of the PR
Found while scanning `hugegraph-server/hugegraph-dist` for small,
test-backed fixes. No issue was filed. Two startup errors lost the exception
that caused them:
- `RegisterUtil.registerPlugins` threw `new HugeException("Failed to load
plugin '%s'", plugin.name(), e)`. With a `String` as the second argument, Java
picks the `HugeException(String, Object...)` constructor, so `e` was an unused
format argument and the exception had no cause. A plugin whose `register()`
failed stopped the server with only the plugin name.
- `HugeGremlinServer.startPrepared` logged `t.getMessage()` when Gremlin
Server failed to start, then threw `new HugeException("Failed to start Gremlin
Server")` without `t`.
## Main Changes
- `RegisterUtil.registerPlugins`: pass `e` as the cause, `("...'%s'", e,
plugin.name())`.
- `HugeGremlinServer.startPrepared`: pass `t` as the cause.
- Messages and exception types are unchanged. Stack traces printed for these
failures now end with a `Caused by:` section.
- Add `RegisterUtilPluginTest` in `hugegraph-dist/src/test` (surefire runs
it in the dist module; it serves a failing test plugin through a temporary
`META-INF/services` file and restores the context class loader afterwards), and
`ContextGremlinServerHttpTest.testStartFailureKeepsCause` (a mocked
`GremlinServer` whose start fails; the class is already in `UnitTestSuite`).
## Verifying these changes
- [ ] Trivial rework / code cleanup without any test coverage. (No Need)
- [ ] Already covered by existing tests, such as *(please modify tests
here)*.
- [x] 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
`c3b1e140d`.
- Before the fix (production file checked out from master, new tests
kept), each test fails because the cause is null:
`mvn -ntp -B test -pl hugegraph-server/hugegraph-test -am -P unit-test
-Deditorconfig.skip=true -Dmaven.javadoc.skip=true
-Dtest='RegisterUtilPluginTest,ContextGremlinServerHttpTest'
-Dsurefire.failIfNoSpecifiedTests=false`
`RegisterUtilPluginTest.testPluginRegisterFailureKeepsCause: expected
same:<java.lang.IllegalStateException: Failed to register test plugin> was
not:<null>`
`ContextGremlinServerHttpTest.testStartFailureKeepsCause: expected
same:<java.lang.RuntimeException: Address already in use> was not:<null>` (run
with only `HugeGremlinServer.java` reverted, since the first failure stops the
build in `hugegraph-dist`).
- With the fix:
`mvn -ntp -B test -pl hugegraph-server/hugegraph-test -am -P unit-test
-Deditorconfig.skip=true -Dmaven.javadoc.skip=true`
Result: BUILD SUCCESS. In `hugegraph-dist`, `RegisterUtilPluginTest`
ran 1 test, 0 failures. `UnitTestSuite` ran 1427 tests, 0 failures, 0 errors, 8
skipped, including the new Gremlin test. A branch with master's tests (#3459)
ran 1426 on the same host.
- `-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]