bitflicker64 opened a new pull request, #3456:
URL: https://github.com/apache/hugegraph/pull/3456
## Purpose of the PR
Found while scanning `hugegraph-commons/hugegraph-common` for small,
test-backed fixes. No issue was filed; each fix comes with a unit test that
fails on master.
- `BatchMapperIterator` had no `close()` override, so `close()` closed only
the origin iterator. A batch iterator returned by the mapper and left partly
read was never closed. The Server hits this in
`GraphTransaction.queryAdjacentVertices` and `HugeVertexStepByBatch` when a
traversal stops early, for example on a limit. `FlatMapperIterator.close()`
already closes its batch iterator first.
- `MachineInfo.getIpAddress()` set its cache to an empty list before the
lookup. If the lookup threw, every later call returned `[]` without retrying.
PD's `LicenseVerifierService` reads this list. #3335 fixed the same problem in
`getMacAddress()`.
- `WrappedIterator.close(Iterator)` and two `MachineInfo` lookups wrapped an
exception without passing it as the cause.
## Main Changes
- `BatchMapperIterator.close()`: close the current batch iterator, then call
`super.close()`. This mirrors `FlatMapperIterator`, including its behaviour
when the batch close throws: the exception propagates and the origin is not
closed on that call.
- `MachineInfo.getIpAddress()`: build the list locally and cache it only
after the lookup succeeds. A lookup that keeps failing now throws on each call
instead of returning a cached `[]`.
- Pass the caught exception as the cause in
`WrappedIterator.close(Iterator)` and in `MachineInfo`. Messages and exception
types are unchanged.
- Add 5 tests to `BatchMapperIteratorTest` and `MachineInfoTest`. Both
classes are 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:
- On master code all 5 new tests fail:
`testCloseClosesCurrentBatchIterator` (batch iterator left open),
`testCloseWithFailingBatchKeepsCause` (nothing thrown),
`testBatchCloseFailureKeepsCause` and `testGetMacByUnboundAddressKeepsCause`
(cause is null), `testGetIpAddressRetriesAfterLookupFailure` (second call
returns the cached `[]`).
- Ran on Linux x86_64, OpenJDK 17.0.20.1, Maven 3.8.7, 2026-11-07, at
`1e8f6bd23`:
`mvn -ntp -B test -pl hugegraph-commons/hugegraph-common -am
-Dtest=UnitTestSuite -DskipCommonsTests=false
-Dsurefire.failIfNoSpecifiedTests=false -Deditorconfig.skip=true`
Result: `UnitTestSuite` ran 397 tests, against 392 on master at
`cd7f1493b`, so all 5 new tests ran and passed.
Two existing tests fail on this host on master too, with the same
assertion: `MachineInfoTest.testGetIpAddressList:54` and
`testGetLocalAllInetAddress:74`. The host has interface addresses that the
test's IP patterns do not match; this PR does not touch those patterns. In this
run `RestClientTest.testPostHttpsWithAllParams` and
`testPostHttpsWithTokenAndAllParams` also timed out connecting to an external
HTTPS host. This PR does not touch `RestClient`, and both tests passed in the
`UnitTestSuite` run of another branch on the same host minutes later.
- `-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]