bitflicker64 opened a new pull request, #899:
URL: https://github.com/apache/hugegraph-toolchain/pull/899
## Purpose of the PR
No linked issue. These came out of a read through
`hugegraph-hubble/hubble-be` (Java only), looking for small bugs and code that
can move to Java 17 syntax without changing behaviour.
`EdgeLabelEntity.equals` calls `this.parentLabel.equals(...)`. A normal edge
label has no parent label (`EdgeLabelService.convert` copies the client's
`parentLabel()`, which is null for it), so when schema reuse finds an edge
label with the same name in the target graph, `SchemaEntity.compare` (called
from `EdgeLabelService.java:268`) throws `NullPointerException` instead of
returning EXISTED or DUPNAME.
## Main Changes
Bug fixes (each covered by a new test that fails without the fix):
- `EdgeLabelEntity.equals` compares `parentLabel` with `Objects.equals`.
Labels that have a parent label compare as before.
- `FileUtil.countLines(File)` passes the `IOException` as the cause of the
`InternalException` it throws. The message is unchanged.
Cleanup, no behaviour change:
- Pattern matching for `instanceof` in the `equals` methods of
`EdgeLabelEntity`, `VertexLabelEntity`, `PropertyKeyEntity`, `PropertyIndex`,
`ParamEntity`, `EdgeMapping` and `VertexMapping`.
No REST endpoint, response shape, config key or database schema changes.
Tests: a new `EdgeLabelEntityTest` (normal labels without a parent label)
and a new case in `FileUtilTest`. Both are plain JUnit tests with no Spring
context or server, and CI picks them up through surefire's default `*Test`
pattern. `EdgeLabelEntityTest` is also listed in `UnitTestSuite` next to
`FileUtilTest`.
Left out on purpose: parent edge labels (no source or target label) still
cannot go through the reuse conflict check. `EdgeLabelService.convert` calls
the client's `sourceLabel()`, which throws for a label without exactly one
link, and `EdgeLabelEntity.getLinkLabels()` passes nulls to `ImmutableSet.of`.
What a parent label should look like in that check is a separate decision.
## 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:
- `mvn -ntp -pl hugegraph-hubble/hubble-be -am test
-Dloader.distribution.skip=true -Dtest=<the 121 hubble-be test classes>
-Dsurefire.failIfNoSpecifiedTests=false` at 2c46c0c1 on JDK 17 (Linux). The
list is every class surefire's default patterns pick up in
`hubble-be/src/test`, which is what `mvn test -P unit-test -pl
hugegraph-hubble/hubble-be` runs in CI: 1277 tests, 0 failures, 0 skipped.
- With only `hugegraph-hubble/hubble-be/src/main` reverted to master,
both new tests fail: `EdgeLabelEntityTest.testEqualsWithoutParentLabel` with
`NullPointerException: ... because "this.parentLabel" is null` in
`EdgeLabelEntity.equals`, and `FileUtilTest.testCountLinesKeepsCause` because
the cause is null.
## Does this PR potentially affect the following parts?
- [x] Nope
- [ ] Dependencies (add/update license info)
- [ ] Modify configurations
- [ ] The public API
- [ ] Other affects (typed here)
## Documentation Status
- [ ] `Doc - TODO`
- [ ] `Doc - Done`
- [x] `Doc - No Need`
--
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]