CommandLineLauncher exits with status 0 when verification fails

Đang mở Phù hợp với người mới
#562 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
1/5
Thời gian dự kiến
Dưới một giờ
Mức phù hợp với người mới
90/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
java
Lĩnh vực
cli

Hướng nghiên cứu

Bắt đầu tại liquidjava.api.CommandLineLauncher.main và tìm nhánh diagnostics.foundError() được hiển thị trong issue. Chỉ thay đổi điểm vào của dòng lệnh để lỗi xác minh trả về trạng thái thoát khác 0, đồng thời giữ cho launch(...) có thể được máy chủ ngôn ngữ VS Code sử dụng. Kiểm tra bằng tệp Java không hợp lệ được cung cấp và một tệp hợp lệ, đảm bảo echo $? chỉ báo lỗi đối với tệp không hợp lệ.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Description
liquidjava.api.CommandLineLauncher always exits with status 0, also when verification finds errors. Scripts, CI jobs and build tools that run the verifier (for example through exec-maven-plugin) therefore cannot tell a failed verification from a passing one by the exit code, and a refinement error never fails the build.

In CommandLineLauncher.main, the error branch prints the diagnostics and returns:

if (diagnostics.foundError()) {
    System.out.println(diagnostics.getErrorOutput());
    return;
}

Minimal reproducer

import liquidjava.specification.Refinement;

final class Bad {
  static void f() {
    @Refinement("_ > 0")
    int a = -1;
  }
}
java -cp liquidjava-verifier/target/liquidjava-verifier-0.0.38.jar \
  liquidjava.api.CommandLineLauncher path/to/folder-with-Bad.java
echo $?

The same happens with the ./liquidjava script and with mvn exec:java (liquidjava.api.CommandLineLauncher as mainClass).

Expected behavior
A non-zero exit status when verification reports errors, and 0 when it passes.

Actual behavior
The error is printed correctly:

Refinement Error: found `a == -1` but expected `a > 0`
5 |     @Refinement("_ > 0")

but echo $? prints 0, the same as for a correct file (Correct! Passed Verification.).

Environment

  • LiquidJava version / commit: 0.0.38, built from main at 6a349c1e (2026-11-24); also with io.github.liquid-java:liquidjava-verifier:0.0.38 from Maven Central
  • Java version (java -version): OpenJDK 21.0.13 (Temurin, in Docker) and OpenJDK 21.0.13.1 (host)
  • OS: Linux

A possible fix might be to exit with a non-zero status in the error branch of main only. launch(...) is also called by the VS Code extension's language server, so a System.exit there would stop the server.

Ngôn ngữ chính
Java
Star
73
Fork
38
Merge trung bình
12 giờ 32 phút
Pull request đã merge (30 ngày)
45

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của liquid-java/liquidjava

Tất cả issue của liquid-java/liquidjava

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.