Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ViolationStoreFactory throws StoreUpdateFailedException when previous run = 0 violations #456

Closed
jbkervyn opened this issue Oct 22, 2020 · 1 comment · Fixed by #457
Closed

Comments

@jbkervyn
Copy link

jbkervyn commented Oct 22, 2020

First run : no violations : emtpy file created.
Second run : no violations : StoreUpdateFailedException

CategorizedViolations the following :
image

this leads to removeObsoleteViolationsFromStore being called and this can trigger an StoreUpdateFailedException

@jbkervyn jbkervyn reopened this Oct 22, 2020
@jbkervyn jbkervyn changed the title ViolationStoreFactory throws StoreUpdateFailedException when violations is emtpy ViolationStoreFactory throws StoreUpdateFailedException when previous run = 0 violations Oct 22, 2020
@hankem
Copy link
Member

hankem commented Oct 22, 2020

Thanks for the report! I can indeed reproduce the issue with the following simple example:

imports
import com.tngtech.archunit.ArchConfiguration;
import com.tngtech.archunit.junit.AnalyzeClasses;
import com.tngtech.archunit.junit.ArchTest;
import com.tngtech.archunit.junit.ArchUnitRunner;
import com.tngtech.archunit.lang.ArchRule;
import org.junit.runner.RunWith;

import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.classes;
import static com.tngtech.archunit.library.freeze.FreezingArchRule.freeze;

@RunWith(ArchUnitRunner.class)
@AnalyzeClasses(packagesOf = Issue456.class)
public class Issue456 {
    static {
        ArchConfiguration.get().setProperty("freeze.store.default.allowStoreCreation", "true");
        ArchConfiguration.get().setProperty("freeze.store.default.allowStoreUpdate", "false");
    }

    ArchRule ruleWithoutViolations = classes().should().haveNameMatching(".*");

    @ArchTest
    ArchRule frozen = freeze(ruleWithoutViolations);
}

hankem added a commit that referenced this issue Oct 22, 2020
Signed-off-by: Manfred Hanke <Manfred.Hanke@tngtech.com>
@hankem hankem linked a pull request Oct 22, 2020 that will close this issue
codecholeric added a commit that referenced this issue Dec 14, 2020
By default `Splitter.on(..).splitToList("")` returns a list containing one element (the empty string). This leads to an inconsistent behavior, because saving no lines will in turn return one line on read. Configuring `Splitter` via `omitEmptyStrings()` we can fix this behavior by skipping all empty lines, which makes sense in general.

Resolves: #456

Signed-off-by: Manfred Hanke <Manfred.Hanke@tngtech.com>
codecholeric added a commit that referenced this issue Feb 21, 2021
By default `Splitter.on(..).splitToList("")` returns a list containing one element (the empty string). This leads to an inconsistent behavior, because saving no lines will in turn return one line on read. Configuring `Splitter` via `omitEmptyStrings()` we can fix this behavior by skipping all empty lines, which makes sense in general.

Resolves: #456

Signed-off-by: Manfred Hanke <Manfred.Hanke@tngtech.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants