Skip to content

Commit 07e82bd

Browse files
committed
fix(java): keep completed indexing jobs terminal across notification workers
1 parent e0b25c2 commit 07e82bd

4 files changed

Lines changed: 122 additions & 4 deletions

File tree

‎README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Java Support for Lithe
22

3-
> **Viva 预览版 Java 支持(1.1.2)**:清单已迁到当前契约 0,后端使用 Core
3+
> **Viva 预览版 Java 支持(1.1.3)**:清单已迁到当前契约 0,后端使用 Core
44
> `65cf82343c5e315aae2e335b2e8f0217b703e89a` 中的 Rust SDK 0.4.0(尚无对应发布标签)。
55
> 本轮验证含第三方 JAR 依赖的普通 Maven 工程:JDT 补全、Maven 编译、main 运行和断点调试,包含变量读取、继续和退出。
66
> 需要同时包含 Lithe 客户端的动作注册解码、动作刷新与首次调试加载修复;未修改这些行为的旧 preview 不能直接使用本包。
@@ -24,7 +24,7 @@
2424
> SDK. Maven and Gradle import settings come from the Maven and Gradle plugins through a function interface that
2525
> Lithe Core relays between plugins.
2626
27-
1.1.2 面向包含主仓库 [#1884](https://github.com/1lck/Lithe-IDEA/pull/1884) 的配套 Viva preview(客户端修订 `607f00967d70a7017d49805183d0d2e6ffdf1c0d` 或更新版本)。API / 能力与传输版本以 `plugin.json`、`sdk.lock.json`
27+
1.1.3 面向包含主仓库 [#1884](https://github.com/1lck/Lithe-IDEA/pull/1884) 的配套 Viva preview(客户端修订 `607f00967d70a7017d49805183d0d2e6ffdf1c0d` 或更新版本)。API / 能力与传输版本以 `plugin.json`、`sdk.lock.json`
2828
和固定 Core 中的[插件资料](https://github.com/Lithe-IDEA/Lithe-core-rust/tree/65cf82343c5e315aae2e335b2e8f0217b703e89a/shared/plugins)为准。
2929
`MIGRATION.md` 保留迁移历史,不能用其中旧宿主、旧 API 数字推断当前兼容性。
3030

‎backend/src/run.rs‎

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ use lithe_plugin_sdk::{
5656
WorkspaceContext,
5757
};
5858
use serde_json::{json, Map};
59-
use std::collections::{HashMap, HashSet};
59+
use std::collections::{HashMap, HashSet, VecDeque};
6060
use std::io::{BufRead, BufReader, Cursor, Write};
6161
use std::net::TcpListener;
6262
use std::path::{Path, PathBuf};
@@ -223,6 +223,9 @@ pub struct RunSession {
223223

224224
const MAX_ACTION_QUERY_REFRESHES: u8 = 3;
225225
const MAX_ACTION_PROGRESS_JOBS: usize = 128;
226+
/// Remember recent terminal job IDs because SDK notification workers may run
227+
/// out of wire order. This per-server history has the same bound as live jobs.
228+
const MAX_COMPLETED_ACTION_PROGRESS_JOBS: usize = 128;
226229

227230
#[derive(Default)]
228231
struct ActionQueryRetry {
@@ -233,6 +236,7 @@ struct ActionQueryRetry {
233236
degraded: bool,
234237
exhausted_reported: bool,
235238
active_work: HashSet<String>,
239+
completed_jobs: VecDeque<String>,
236240
progress_limit: bool,
237241
}
238242

@@ -254,8 +258,17 @@ impl ActionQueryRetry {
254258
}
255259

256260
fn progress(&mut self, id: &str, complete: bool) -> bool {
261+
// Completion is terminal for a JDT job ID. A delayed worker must not
262+
// resurrect it, nor may a duplicate end consume another retry budget.
263+
if self.completed_jobs.iter().any(|completed| completed == id) {
264+
return false;
265+
}
257266
if complete {
258267
self.active_work.remove(id);
268+
if self.completed_jobs.len() == MAX_COMPLETED_ACTION_PROGRESS_JOBS {
269+
self.completed_jobs.pop_front();
270+
}
271+
self.completed_jobs.push_back(id.to_owned());
259272
if self.active_work.is_empty() && !self.progress_limit {
260273
return self.work_completed();
261274
}
@@ -1520,6 +1533,45 @@ mod tests {
15201533
);
15211534
}
15221535

1536+
#[test]
1537+
fn completed_progress_cannot_be_resurrected_by_a_late_worker() {
1538+
let mut retry = ActionQueryRetry::default();
1539+
// SDK notification workers can acquire the lock in a different order
1540+
// from the wire: an earlier running update may follow completion.
1541+
assert!(!retry.progress("build", true));
1542+
assert!(!retry.progress("build", false));
1543+
assert!(!retry.progress("index", false));
1544+
assert_eq!(retry.defer(retry.completed_work), (true, false));
1545+
assert!(
1546+
retry.progress("index", true),
1547+
"late build update must not block recovery"
1548+
);
1549+
let completed = retry.completed_work;
1550+
assert!(!retry.progress("index", true));
1551+
assert_eq!(
1552+
retry.completed_work, completed,
1553+
"duplicate completion is not new work"
1554+
);
1555+
}
1556+
1557+
#[test]
1558+
fn terminal_progress_history_is_bounded_and_keeps_recent_jobs() {
1559+
let mut retry = ActionQueryRetry::default();
1560+
for id in 0..MAX_COMPLETED_ACTION_PROGRESS_JOBS * 2 {
1561+
retry.progress(&id.to_string(), true);
1562+
}
1563+
assert_eq!(
1564+
retry.completed_jobs.len(),
1565+
MAX_COMPLETED_ACTION_PROGRESS_JOBS
1566+
);
1567+
let recent = (MAX_COMPLETED_ACTION_PROGRESS_JOBS * 2 - 1).to_string();
1568+
let completed = retry.completed_work;
1569+
retry.progress(&recent, false);
1570+
retry.progress(&recent, true);
1571+
assert!(retry.active_work.is_empty());
1572+
assert_eq!(retry.completed_work, completed);
1573+
}
1574+
15231575
#[test]
15241576
fn progress_bookkeeping_is_bounded_and_malformed_events_do_not_recover() {
15251577
let mut retry = ActionQueryRetry::default();

‎docs/releases/v1.1.3.md‎

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
## 中文
2+
3+
Java Support 1.1.3 为配套 Viva 预览版提供 Java 项目支持。本版本是预发布,插件包不带发布者签名。
4+
5+
### 下载与安装
6+
7+
下载本页对应系统的 ZIP:macOS Apple Silicon(`darwin-arm64`)、macOS Intel(`darwin-x64`)或 Windows x64(`windows-x64`)。在兼容 Viva 客户端的插件设置中选择从文件安装 ZIP。
8+
9+
需要包含 [Lithe #1884](https://github.com/1lck/Lithe-IDEA/pull/1884) 的客户端(修订 `607f00967d70a7017d49805183d0d2e6ffdf1c0d` 或更新版本)及 Core #29。旧版 macOS Lithe 和未包含这些修复的 Viva preview 不受支持。插件使用契约/API/能力版本 0;语言服务器使用随包 Temurin 21,项目运行仍使用用户选择的 JDK。
10+
11+
Maven 项目配合 Maven 0.0.1;Gradle 项目配合 Gradle 1.0.0。构建工具由用户安装或由项目 Wrapper 提供。
12+
13+
### 更新
14+
15+
- 修复并发处理索引进度时,晚到的旧更新重新激活已完成任务、导致运行动作不恢复的问题;终态历史有界且不增加后台轮询。
16+
- 补齐自身 LICENSE/NOTICE 与 Rust 构建依赖的许可和哈希清单,缺失时阻止打包。
17+
18+
- 跑通普通 Maven、Gradle 和普通 Java 目录的补全、编译、运行及断点调试,Java 8 项目保留正确的编译目标。
19+
- Windows 后端静态链接编译器运行库,发布检查拒绝额外的 VC++/MinGW 运行库依赖。
20+
- 修复 Windows 可执行路径、中文/UNC 文件 URI、Lombok 加载及过长 classpath;退出后清理临时 classpath JAR。
21+
- 冷索引暂时无法返回运行动作时,在索引任务完成后有界恢复,不增加后台轮询。
22+
- 已在 macOS 与 Windows 无头验证断点变量、继续/停止、编译错误阻止运行旧 class、暂停时关闭及插件安装目录只读。
23+
24+
### 兼容性与已知限制
25+
26+
- 二进制依赖类跳转尚未接通:语言服务器能返回 `jdt:` 目标,但插件未注册对应内容提供者,Viva 无法打开类内容;不保证反编译视图或类间继续跳转。
27+
- `.jsp` 当前按 HTML 打开,没有 Java 语言服务接管,JSP 内的 Java 补全与跳转不受支持。
28+
29+
尚未完整验收原生窗口、全部日志/取消路径、JUnit/TestNG 行内运行器和 Spring/MyBatis。JSP HTTP/Servlet 调试通过不代表 JSP 源码补全或 JSP 断点;Ant 源码布局不代表执行 Ant target。Java 5/7 源码级别、长 module-path、JavaCC 生成模型、多版本 JAR 和部分旧泛型项目仍有限制,详见 README 与主仓库 #1881–1883。
30+
31+
实测 JDT 内存与补全延迟没有显著改善,本版本不宣称整体性能提升。Windows 的真实工作流在 ARM Windows 上使用 x64 工具验证,其耗时不代表原生 AMD64 性能。
32+
33+
---
34+
35+
## English
36+
37+
Java Support 1.1.3 targets the matching Viva preview. This is a prerelease with unsigned plugin archives.
38+
39+
### Download and installation
40+
41+
Choose the ZIP for macOS Apple Silicon (`darwin-arm64`), macOS Intel (`darwin-x64`), or Windows x64 (`windows-x64`), then install it from a file in the compatible Viva client's plugin settings.
42+
43+
The client must include [Lithe #1884](https://github.com/1lck/Lithe-IDEA/pull/1884), revision `607f00967d70a7017d49805183d0d2e6ffdf1c0d` or newer, and Core #29. Legacy macOS Lithe and earlier Viva previews are unsupported. Contract, API and capability versions are 0. Bundled Temurin 21 runs the language server; project execution uses the selected project JDK.
44+
45+
Use Maven 0.0.1 for Maven projects and Gradle 1.0.0 for Gradle projects. Supply the build tool yourself or through the project's wrapper.
46+
47+
### Changes
48+
49+
- Prevent late progress updates from resurrecting completed indexing jobs and blocking run-action recovery; terminal history is bounded without polling.
50+
- Include project and Rust dependency notices with a hash manifest; missing notices stop packaging.
51+
52+
- Validated completion, compilation, execution and breakpoint debugging for ordinary Maven, Gradle and plain Java projects, preserving Java 8 compilation targets.
53+
- The Windows backend statically links compiler runtimes; release checks reject extra VC++/MinGW runtime DLL dependencies.
54+
- Fixed Windows executable paths, Unicode/UNC file URIs, Lombok loading and long classpaths; temporary classpath JARs are removed after execution.
55+
- Recover run actions after cold-index jobs finish, with bounded retries and no background polling.
56+
- Headless macOS and Windows workflows cover breakpoint locals, continue/stop, refusal to run stale classes after compilation errors, closing paused sessions and read-only installed packages.
57+
58+
### Compatibility and known limitations
59+
60+
- Navigation into binary dependency classes is not wired up: the language server returns `jdt:` targets, but no matching content provider is registered, so Viva cannot open them. Decompiled views and further navigation between classes are not supported.
61+
- `.jsp` files currently open as HTML without a Java language service; Java completion and navigation inside JSP are unsupported.
62+
63+
Native windows, all logging/cancellation paths, inline JUnit/TestNG and Spring/MyBatis have not been fully accepted. JSP HTTP/Servlet debugging does not cover JSP-source completion or JSP breakpoints; Ant source layouts do not cover Ant targets. Java 5/7 source levels, long module-paths, JavaCC models, multi-release JARs and some older generic code remain limited; see README and Lithe #1881–1883.
64+
65+
Measurements found no significant JDT memory or completion-latency improvement. Windows workflows used x64 tools on ARM Windows, so their timings do not represent native AMD64 performance.
66+

‎io.github.lithe-idea.java-support/plugin.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"schemaVersion": 0,
33
"id": "io.github.lithe-idea.java-support",
44
"displayName": "Java Support",
5-
"version": "1.1.2",
5+
"version": "1.1.3",
66
"pluginAPIVersion": 0,
77
"requires": {"backend": 0, "debugAdapters": 0, "languages": 0, "languageServers": 0, "pluginFunctions": 0, "settings": 0, "projectGenerators": 0, "toolDefinitions": 0},
88
"requiresTools": ["java"],

0 commit comments

Comments
 (0)