fix(server): ensure backend is initialized in gremlin script by zmrlft · Pull Request #2824 · apache/hugegraph

@zmrlft

Purpose of the PR

Main Changes

The fundamental reason is that HugeFactory.open () returns an instance of StandardHugeGraph, but its backend storage has not been initialized yet. I added initBackend below for initialization

Verifying these changes

  • Trivial rework / code cleanup without any test coverage. (No Need)
  • Already covered by existing tests, such as (please modify tests here).
  • Need tests and can be verified as follows:
    • xxx

Does this PR potentially affect the following parts?

Documentation Status

  • Doc - TODO
  • Doc - Done
  • Doc - No Need

@dosubot dosubot bot added size:XS

This PR changes 0-9 lines, ignoring generated files.

bug

Something isn't working

labels

Jun 29, 2025

@codecov

Codecov Report

Attention: Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.

Project coverage is 0.08%. Comparing base (e139465) to head (a23d1d0).

Files with missing lines Patch % Lines
...n/java/org/apache/hugegraph/StandardHugeGraph.java 0.00% 4 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (e139465) and HEAD (a23d1d0). Click for more details.

HEAD has 3 uploads less than BASE
Flag BASE (e139465) HEAD (a23d1d0)
4 1
Additional details and impacted files
@@             Coverage Diff              @@
##             master   #2824       +/-   ##
============================================
- Coverage     42.87%   0.08%   -42.79%     
+ Complexity      458      22      -436     
============================================
  Files           758     725       -33     
  Lines         61313   57652     -3661     
  Branches       7877    7232      -645     
============================================
- Hits          26286      51    -26235     
- Misses        32311   57599    +25288     
+ Partials       2716       2     -2714     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@VGalaxies

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR ensures that the backend stores are initialized when a StandardHugeGraph instance is created by calling each store’s open(...) and the storeProvider.init() in the constructor.

  • Added explicit calls to open schema, system, and graph stores
  • Initialized the storeProvider immediately after store opens
Comments suppressed due to low confidence (1)

hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/StandardHugeGraph.java:249

  • Consider adding a unit test that constructs StandardHugeGraph and verifies the stores are open and storeProvider is initialized to prevent regressions.
            this.loadSchemaStore().open(this.configuration);

try {

this.loadSchemaStore().open(this.configuration);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] These sequential store open calls and storeProvider.init() could be extracted into a private initBackend() helper to improve readability and avoid constructor bloat.

Copilot uses AI. Check for mistakes.

@zmrlft

@zmrlft zmrlft changed the title fix(server): ensure backend is initialized in StandardHugeGraph const… fix(server): ensure backend is initialized in gremlin script

Jun 30, 2025

@zmrlft

imbajin

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

THX~

@dosubot dosubot bot added the lgtm

This PR has been approved by a maintainer

label

Jul 1, 2025

Pengzna

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VGalaxies