Skip to content

Divergent loop (each application of the formatter causes new changes) #89

@nedtwigg

Description

@nedtwigg

There's a reproducible divergent loop on this file:

apache-geode/geode-core/src/main/java/org/apache/geode/internal/cache/LocalRegion.java

Each time the formatter is called, it adds two newlines above the <pre> tag on line 684, and two newlines above the closing </code> tag on line 695.

Perhaps related to #84? If you call the formatter 10 times, then you end up with 20 newlines in each of these places.

We found this bug using the "padded cell" functionality in Spotless, which checks that Formatter(Formatter(input)) == Formatter(input), and handles misbehaving rules by resolving cycles, ignoring divergence, etc. Whenever a violation is found, it generates a set of files for reproducing the issue which demonstrate the cycle or divergence.

There's an open PR on this project to point gradle users to this Spotless plugin. People who use it will likely be able to find other helpful testcases, while insulating them from the bug in the short-term.

If you'd like to reproduce this for yourself, clone https://github.com/nedtwigg/incubator-geode, and checkout tag Bug37. Run gradlew spotlessCheck and it'll tell you which files are divergent and the testcases will be in build/spotless-diagnose-java.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions