getClosestPath loops indefinitely when the requested path and its parent are both missing #3230
Viacheslav Petrenko opened 57 minutes ago

Observed on OneDev Server 17.0.2 (JGit 7.8.0, Java 25.0.4.1). The same loop is present in the 17.1.1 source.

Minimal service-level reproduction

  1. In a disposable test project, commit src/keep.txt. Leave src/missing absent.
  2. In a server integration test, resolve that commit to revId and call gitService.getClosestPath(project, revId, "src/missing/File.java"). Run the test in a disposable JVM with an external timeout.
  3. Expected: the call returns "src", the nearest existing ancestor. Actual lookup sequence from the installed bytecode: src/missing/File.java → src/missing → src/missing → … . The call cannot reach src.

The lookup tests currentPath, but both the slash check and the parent calculation use the original path. After the first miss the loop keeps assigning the same value to currentPath. Computing the parent from currentPath on each iteration should also allow the existing null fallback to be reached when no ancestor exists.

Runtime evidence

A single runnable Hazelcast executor thread accumulated 40.26 hours of CPU over 41.49 hours elapsed (0.97 of one logical CPU on average). Repeated 10-second Linux per-thread samples measured about 0.99 CPU; a separate 5-second sample measured 0.94. Two JVM thread dumps showed the same worker in this call chain (excerpt, infrastructure identifiers omitted):

java.lang.Thread.State: RUNNABLE
    at org.eclipse.jgit.treewalk.TreeWalk.forPath(TreeWalk.java:187)
    at org.eclipse.jgit.treewalk.TreeWalk.forPath(TreeWalk.java:232)
    at org.eclipse.jgit.treewalk.TreeWalk.forPath(TreeWalk.java:264)
    at io.onedev.server.git.service.DefaultGitService.lambda$getClosestPath$f7d724b1$1(DefaultGitService.java:345)
    ...
    at java.util.concurrent.FutureTask.run(FutureTask.java:328)
    at com.hazelcast.executor.impl.DistributedExecutorService$Processor.run(DistributedExecutorService.java:285)

The live request's path and revision were not captured. The synthetic path above illustrates the termination defect independently of that request.

1/1
Type
Bug
Priority
Normal
Assignee
Affected Versions
17.0.2 (observed), 17.1.1 (verified in source)
Labels
No labels
Issue Votes (0)
Watchers (2)
Reference
OD-3230
Please wait...
Connection lost or session expired, reload to recover
Page is in error, reload to recover