Skip to content

Commit 71315dd

Browse files
authored
Merge main into develop (#5424)
2 parents b6729da + a014e92 commit 71315dd

3 files changed

Lines changed: 95 additions & 1 deletion

File tree

AGENTS.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,18 @@ It is illegal to `-q` when running tests!
166166

167167
---
168168

169+
## Always Install Before Tests (Required)
170+
171+
The Maven reactor resolves inter-module dependencies from the local Maven repository (`~/.m2/repository`).
172+
Running `install` publishes your changed modules there so downstream modules and tests pick up the correct versions.
173+
174+
- Always run `mvn -o -Pquick install | tail -200` before you start working. This command typically takes between 10 and 30 seconds.
175+
- Always run `mvn -o -pl <module> -am -Pquick install | tail -200` before any `verify` or test runs.
176+
- If offline resolution fails due to a missing dependency or plugin, rerun the exact `install` command once without `-o`, then return offline.
177+
- Skipping this step can lead to stale or missing artifacts during tests, producing confusing compilation or linkage errors.
178+
- Never ever change the repo location. Never use `-Dmaven.repo.local=.m2_repo`. Instead, ask for permission the first time you run `mvn -o -Pquick install | tail -200`.
179+
---
180+
169181
## Quick Start (First 10 Minutes)
170182

171183
1. **Discover**
@@ -176,6 +188,7 @@ It is illegal to `-q` when running tests!
176188

177189
* **Preferred:** `mvn -o -Pquick install | tail -200`
178190
* **Alternative:** `mvn -o -Pquick install | tail -200`
191+
* This step is required before any tests. It installs artifacts to `~/.m2` so the reactor resolves fresh inter-module dependencies.
179192
3. **Format (Java, imports, XML)**
180193

181194
* `mvn -o -q -T 2C formatter:format impsort:sort xml-format:xml-format`
@@ -184,6 +197,7 @@ It is illegal to `-q` when running tests!
184197
* By module: `mvn -o -pl <module> verify | tail -500`
185198
* Single class: `mvn -o -pl <module> -Dtest=ClassName verify | tail -500`
186199
* Single method: `mvn -o -pl <module> -Dtest=ClassName#method verify | tail -500`
200+
* Prerequisite: ensure `mvn -o -Pquick install` (root or `-pl <module> -am`) has just run so artifacts are available in `~/.m2`.
187201
5. **Inspect failures**
188202

189203
* **Unit (Surefire):** `<module>/target/surefire-reports/`
@@ -483,6 +497,39 @@ Do **not** modify existing headers’ years.
483497
484498
---
485499
500+
## Branching & Commit Conventions
501+
502+
- Branch names: start with `GH-XXXX` where `XXXX` is the GitHub issue number. Prefer a short, kebab‑case slug after the number when helpful, e.g., `GH-1234-add-trig-writer-check`.
503+
- Commit messages: start with the same prefix, `GH-XXXX <short summary>`, on every commit in the branch.
504+
- Keep summaries concise, in imperative mood (e.g., “Fix NPE in TriG writer”).
505+
- Example:
506+
- Branch: `GH-1234-add-shacl-validation-metric`
507+
- Commit: `GH-1234 Fix NPE when serializing empty graph`
508+
509+
---
510+
511+
## Branch & PR Workflow (Agent)
512+
513+
- Name branch: `GH-<issue>-<short-slug>` (kebab‑case slug).
514+
- Create branch: `git checkout -b GH-XXXX-your-slug`.
515+
- Stage changes: `git add -A` (ensure new Java files have the required header).
516+
- Optional but recommended: run format + quick install.
517+
- `mvn -o -q -T 2C formatter:format impsort:sort xml-format:xml-format`
518+
- `mvn -o -Pquick install | tail -200`
519+
- Commit: `git commit -m "GH-XXXX <short imperative summary>"`.
520+
- Push branch: `git push -u origin GH-XXXX-your-slug`.
521+
- Create PR using default template:
522+
- Preferred: `gh pr create --title "GH-XXXX <summary>" --body-file .github/pull_request_template.md`
523+
- Fallback: `gh pr create --title "GH-XXXX <summary>" --body "$(cat .github/pull_request_template.md)"`
524+
- Immediately fill the template (do not leave placeholders):
525+
- Set `GitHub issue resolved: #XXXX`.
526+
- Write a short, accurate change summary (what/why).
527+
- Tick applicable checklist items only (self-contained, tests, squashed, commit message prefix, formatting if run).
528+
- Include `Fixes #XXXX` to auto-close the issue on merge.
529+
- Target the repo default branch (e.g., `origin/HEAD`).
530+
531+
---
532+
486533
## Navigation & Search
487534
488535
* Fast file search: `rg --files`

core/sail/extensible-store/src/main/java/org/eclipse/rdf4j/sail/extensiblestore/evaluationstatistics/ExtensibleDynamicEvaluationStatistics.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ protected double getObjectCardinality(Var var) {
228228
@Override
229229
protected double getContextCardinality(Var var) {
230230
synchronized (monitor) {
231-
if (var.getValue() == null) {
231+
if (var == null || var.getValue() == null) {
232232
return defaultContext.cardinality() - defaultContext_removed.cardinality();
233233
} else {
234234
return getHllCardinality(contextIndex, contextIndex_removed, var.getValue());
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/**
2+
* ******************************************************************************
3+
* Copyright (c) 2025 Eclipse RDF4J contributors.
4+
*
5+
* All rights reserved. This program and the accompanying materials
6+
* are made available under the terms of the Eclipse Distribution License v1.0
7+
* which accompanies this distribution, and is available at
8+
* http://www.eclipse.org/org/documents/edl-v10.php.
9+
*
10+
* SPDX-License-Identifier: BSD-3-Clause
11+
* ******************************************************************************
12+
*/
13+
package org.eclipse.rdf4j.sail.extensiblestore.evaluationstatistics;
14+
15+
import static org.junit.jupiter.api.Assertions.assertEquals;
16+
17+
import org.eclipse.rdf4j.query.algebra.Var;
18+
import org.eclipse.rdf4j.query.algebra.ZeroLengthPath;
19+
import org.junit.jupiter.api.Test;
20+
21+
/**
22+
* Reproduces a NullPointerException in ExtensibleDynamicEvaluationStatistics when evaluating the cardinality of a
23+
* ZeroLengthPath with a null context variable.
24+
*
25+
* The EvaluationStatistics visitor for ZeroLengthPath calls getContextCardinality(node.getContextVar()) where the
26+
* context var may be null. The overridden implementation in ExtensibleDynamicEvaluationStatistics assumed a non-null
27+
* Var and dereferenced it, causing an NPE.
28+
*/
29+
public class ExtensibleDynamicEvaluationStatisticsNullContextTest {
30+
31+
@Test
32+
public void testZeroLengthPathWithNullContextDoesNotThrow() {
33+
// Given a dynamic evaluation statistics instance with no data loaded
34+
ExtensibleDynamicEvaluationStatistics stats = new ExtensibleDynamicEvaluationStatistics(null);
35+
36+
// And a ZeroLengthPath with subject and object vars, but no context var (null)
37+
ZeroLengthPath zlp = new ZeroLengthPath(new Var("s"), new Var("o"));
38+
39+
// When asking for cardinality, this used to throw a NullPointerException because
40+
// getContextCardinality(Var var) dereferenced var without checking for null.
41+
// Then it should simply return a numeric value (0.0 with empty stats), not throw.
42+
double cardinality = stats.getCardinality(zlp);
43+
44+
// With no statements added, subject/object/context cardinalities are 0 -> overall 0
45+
assertEquals(0.0, cardinality);
46+
}
47+
}

0 commit comments

Comments
 (0)