A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pmd/pmd/issues/1035 below:

False positive on lambda expression in finally block · Issue #1035 · pmd/pmd · GitHub

Affects PMD Version:
5.6.1

Rule:
ReturnFromFinallyBlock Priority:3 Avoid returning from a finally block

Description:

Code Sample demonstrating the issue:

try {
    ...
} catch (Exception e) {
    ...
} finally {
    Collection<ServiceExecutionEntry> untracked = serviceExecutionTracker.untrackMatchingEntries(e -> {
        ServiceExecutionIdentifiers ids = e.getIdentifiers();
        Long execBqiId = (ids == null) ? null : ids.getBqiId();
        return Objects.equals(bqiId, execBqiId);
    });
    untracked.forEach(e -> logger.info("overwriteLastBqi(bqId={}, bqiId={}) untracked {}", bqId, bqiId, e));
}

Obviously, the code in the finally block does not return - PMD mistakes the return statement in the lambda expression as a return from the finally block

Running PMD through: [Maven]

Apache Maven 3.5.3 (3383c37e1f9e9b3bc3df5050c29c8aff9f295297; 2018-02-24T21:49:05+02:00)
Maven home: /home/lyor/Software/apache-maven-3.5.3
Java version: 1.8.0_162, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.162-3.b12.fc27.x86_64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.15.14-300.fc27.x86_64", arch: "amd64", family: "unix"

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4