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

   ## Purpose of the PR
   
   Found while scanning `hugegraph-server/hugegraph-api` for small, test-backed 
fixes. No issue was filed.
   
   - `CypherManager.getConfigFile` falls back to the classpath when the Cypher 
client config (`conf/remote-objects.yaml` for `CypherAPI`) is not on disk, then 
ran `assert resource != null`. When the file is in neither place, the server 
(no `-ea`) threw a bare `NullPointerException` from `resource.getFile()` and 
tests threw `AssertionError`. The `IllegalArgumentException("Configuration file 
at '%s' does not exist")` written for this case was only reached when the 
resource existed but its file did not.
   - `CypherManager.loadYaml` opened a `FileReader` and never closed it, so 
each config load leaked a file handle.
   
   ## Main Changes
   
   - `CypherManager.getConfigFile`: treat a missing classpath resource like a 
missing file and throw the existing `IllegalArgumentException`. For a Cypher 
REST request on a server without the file, the response changes from HTTP 500 
(bare NPE) to HTTP 400 with that message, the same response the code already 
gave when the resource was found without a file.
   - `CypherManager.loadYaml`: open the reader in try-with-resources. 
`YAMLConfiguration.read` reads the whole stream before returning, and errors 
are wrapped exactly as before.
   - `CypherClient.normalize`: use the pattern variable `matchedPath` instead 
of copying it into a second local.
   - `CypherTemporalFunctions`: use an `instanceof` pattern variable for the 
`Date` value.
   - Add `CypherClientTest.testMissingConfigFileIsReported`. `CypherClientTest` 
is already in `UnitTestSuite`. The config is loaded before any connection is 
opened, so the test needs no server.
   
   No public or protected signature, config key, log message 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, at 
`245d4c41d`.
       - Before the fix (`CypherManager.java` checked out from master, new test 
kept):
         `mvn -ntp -B test -pl hugegraph-server/hugegraph-test -am -P unit-test 
-Deditorconfig.skip=true -Dmaven.javadoc.skip=true -Dtest='CypherClientTest' 
-Dsurefire.failIfNoSpecifiedTests=false`
         `testMissingConfigFileIsReported` fails: `Bad exception type 
java.lang.AssertionError(expected java.lang.IllegalArgumentException)`.
       - 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, `UnitTestSuite` ran 1427 tests, 0 failures, 0 
errors, 8 skipped (master runs 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]

Reply via email to