Skip to content

Java's try-with-resources is not supported #628

@shanshin

Description

@shanshin

Describe the bug
When using try-with-resources in a Java class, some lines are marked as partially covered in the generated report.

Expected behavior
All lines should be fully covered (green in HTML report)

Reproducer
Java class

public final class TryWithResources {

    private TryWithResources() {}

    public static void test() throws Exception {
        final AutoCloseable autoCloseable = new AutoCloseable() {
            @Override
            public void close() {
                System.out.println("closed");
            }
        };

        try (autoCloseable) {
            System.out.println("action");
        }
    }
}

Reports
when calling the test method, the following coverage report is generated
HTML report

Environment

  • IntelliJ agent 1.0.754

Metadata

Metadata

Assignees

Labels

BugBug issue typeS: ready for releaseStatus: merged in the main branch

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions