bitflicker64 opened a new pull request, #3465:
URL: https://github.com/apache/hugegraph/pull/3465

   ## Purpose of the PR
   
   Found while scanning `hugegraph-pd` for small, test-backed fixes. No issue 
was filed; each fix comes with a unit test that fails on master.
   
   - `model.Partition` (the partition view used by the PD REST API) trims the 
2-character postfix from the stored graph name. When the guarded trim was 
added, the old unconditional `substring` was left after it, so the name is 
trimmed twice: `DEFAULT/hugegraph/g` becomes `DEFAULT/hugegra`, and a short 
name such as `g` throws `StringIndexOutOfBoundsException`.
   - `KVPair.hashCode()` threw `NullPointerException` for a null key, while 
`equals()` handles null.
   - `DateUtil.getDate` wrapped a `ParseException` in a `PDException` without 
the cause.
   
   ## Main Changes
   
   - `Partition`: drop the leftover second trim. The guarded trim and its log 
message for short names stay. `Partition` is built only by `GraphStatistics`, 
so the visible change is `partitions[].graphName` in `GET /v1/graphs` and `GET 
/v1/graph/**`: it now equals the parent `graphName` (`DEFAULT/hugegraph`) 
instead of `DEFAULT/hugegra`, with the same JSON shape. The double trim came in 
with d926ec1a (in 1.7.0); before that the name was trimmed once. A graph name 
short enough to make the second `substring` throw no longer turns those 
requests into HTTP 500.
   - `KVPair.hashCode()`: use `Objects.hashCode(key)`; hash values for non-null 
keys are unchanged.
   - `DateUtil.getDate`: pass the `ParseException` as the cause; the message 
and error code are unchanged.
   - Tests: fill the empty `KVPairTest.testHashCode`, and add `PartitionTest` 
(in `org.apache.hugegraph.pd.model`, since `Partition` is package-private) and 
`DateUtilTest`, both registered in `CommonSuiteTest` (`pd-common-test`).
   
   No public or protected signature, stored key or value, gRPC message, config 
key or lock changes.
   
   ## 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.
         `mvn -ntp -B test -pl hugegraph-pd/hg-pd-test -am -P pd-common-test 
-Deditorconfig.skip=true -Dmaven.javadoc.skip=true`
       - Before the fix (tests added, production code as on master): 
`CommonSuiteTest` ran 86 tests with 2 failures and 2 errors, all four in the 
new tests: `expected:<DEFAULT/hugegra[ph]> but was:<DEFAULT/hugegra[]>`, 
`StringIndexOutOfBoundsException: begin 0, end -1, length 1` for the name `g`, 
a NullPointerException in `KVPairTest.testHashCode`, and a null cause in 
`DateUtilTest`.
       - With the fix, at `a7ee0a145`: BUILD SUCCESS, `CommonSuiteTest` ran 86 
tests, 0 failures, 0 errors.
       - `-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]

Reply via email to