A RetroSearch Logo

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

Search Query:

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

false-positive on Pattern Matching with instanceof · Issue #5318 · pmd/pmd · GitHub

Affects PMD Version: 7.7.0

Rule: PreserveStackTraceRule

Please provide the rule name and a link to the rule documentation:
https://docs.pmd-code.org/latest/pmd_rules_java_bestpractices.html#preservestacktrace

Description: using instanceof's Pattern Matching variable counts as PreserveStackTrace rule breaker

Code Sample demonstrating the issue:

        try {
          ......
        } catch (RuntimeException ex) {
            throw ex instanceof ExpirationException expirationException
                    ? expirationExceptionHandler.handle(expirationException)
                    : ex;
        }

Expected outcome:

PMD reports a violation at line throw ex instanceof ExpirationException expirationException, but that's wrong. That's a false positive.

Running PMD through: Maven


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