bitflicker64 opened a new pull request, #895:
URL: https://github.com/apache/hugegraph-toolchain/pull/895
## Purpose of the PR
No linked issue. These came out of a read through `hugegraph-client`,
looking for small bugs and code that can move to Java 17 syntax without
changing behaviour.
Two of them throw where they should not:
- `EdgeLabel.toString()` calls `sourceLabel()` and `targetLabel()`, which
`checkState(links.size() == 1)`. Since #628, calling `toString()` on a parent
edge label (no links) or a label with two `link(...)` calls throws
`IllegalStateException`, so logging such a label or building an assertion
message with it fails.
- `VertexAPI.update(BatchOlapPropertyRequest)` builds its error message with
`size.getClass()`. When the response has no `size` key, the caller gets a
`NullPointerException` instead of the intended `InvalidResponseException`.
## Main Changes
Bug fixes (each covered by a new test that fails without the fix):
- `EdgeLabel.toString()` prints `sourceLabel=null, targetLabel=null` when
the label does not have exactly one link. Output for single-link labels is
unchanged.
- `VertexAPI.update(BatchOlapPropertyRequest)` passes `null` as the class in
the message when `size` is missing.
- `KoutRequest`: add the missing space in "...path or edge when count only
is true".
- `KoutRequest` and `KneighborRequest` `toString()`: add the missing comma
after `maxDepth`. `CountRequest.toString()`: add the closing `}`.
Cleanup, no behaviour change:
- Pattern matching for `instanceof` where a cast of the same variable
follows the check: `AuthAPI`, `Access`, `Belong`, `HugeResource`, `Path`,
`ResultSet`, `VertexAPI`.
- `ComputerDisAPI.parseTaskId` had the same body, constants and messages as
`TaskAPI.parseTaskId`; it now delegates. The public signature stays.
- `PDHugeClientFactory.createClient`: drop a `DefaultHugeClientFactory`
local that was never used (its constructor only stores the array).
No public or protected signature, REST path, or request or response shape
changes.
Tests: four new classes in `unit/`, all registered in `UnitTestSuite`:
`EdgeLabelTest`, `VertexAPITest` (mocked `RestClient`), `TraverserRequestTest`,
and `StructureHelperTest` (the auth setters, `equals`, `Path.attachManager` and
`parseTaskId`, which pin behaviour the cleanup must keep).
Left out on purpose: `EdgeLabelV53` (used by `switchV53()`) still calls
`sourceLabel()` and `targetLabel()` directly, so it throws for the same labels.
Changing what it sends to older servers is not a cleanup, so it is not touched
here.
## 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:
- `cd hugegraph-client && mvn test -Dtest=UnitTestSuite` on JDK 17: 160
tests, 0 failures (143 before this PR).
- With only `src/main` reverted to master, 7 of the new tests fail: the
two `EdgeLabelTest` cases with no link or two links (`IllegalStateException`),
`VertexAPITest.testOlapUpdateWithoutSize` (`NullPointerException`), and the
four `TraverserRequestTest` cases.
- Against a HugeGraph 1.8.0 server with auth on, set up the way
`start-hugegraph-servers.sh` does it (Linux, JDK 17): `ApiTestSuite` 387 tests,
0 failures, 3 skipped. `FuncTestSuite` 96 tests, 0 failures; the one error is
`HugeClientHttpsTest` setup, because that run had no HTTPS server on port 8443.
The change does not touch HTTPS code.
## 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]