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

inlined code detection warnings with try-with-resources #681

Closed
Vampire opened this issue Sep 26, 2019 · 1 comment · Fixed by #683
Closed

inlined code detection warnings with try-with-resources #681

Vampire opened this issue Sep 26, 2019 · 1 comment · Fixed by #683

Comments

@Vampire
Copy link
Contributor

Vampire commented Sep 26, 2019

I have this code:

Properties versionProperties = new Properties();
try (InputStream versionPropertiesStream = versionPropertiesResource.openStream()) {
    versionProperties.load(versionPropertiesStream);
} catch (IOException ignored) {
}

Line 81 is the line with the catch.

When I execute PIT with the inlined code detection enabled, I get four warnings about line 81, I added the mutation details via breakpoint:

09:45:53 PIT >> WARNING : Found more than one mutation similar on same line in a finally block. Can't correct for inlining.
MutationDetails [id=MutationIdentifier [location=Location [clazz=net.kautler.command.api.Version, method=<init>, methodDesc=()V], indexes=[66], mutator=org.pitest.mutationtest.engine.gregor.mutators.VoidMethodCallMutator], filename=Version.java, block=15, lineNumber=81, description=removed call to java/io/InputStream::close, testsInOrder=[], isInFinallyBlock=true, poison=NORMAL]
MutationDetails [id=MutationIdentifier [location=Location [clazz=net.kautler.command.api.Version, method=<init>, methodDesc=()V], indexes=[74], mutator=org.pitest.mutationtest.engine.gregor.mutators.VoidMethodCallMutator], filename=Version.java, block=17, lineNumber=81, description=removed call to java/lang/Throwable::addSuppressed, testsInOrder=[], isInFinallyBlock=true, poison=NORMAL]
MutationDetails [id=MutationIdentifier [location=Location [clazz=net.kautler.command.api.Version, method=<init>, methodDesc=()V], indexes=[79], mutator=org.pitest.mutationtest.engine.gregor.mutators.VoidMethodCallMutator], filename=Version.java, block=19, lineNumber=81, description=removed call to java/io/InputStream::close, testsInOrder=[], isInFinallyBlock=true, poison=NORMAL]
09:45:53 PIT >> WARNING : Found more than one mutation similar on same line in a finally block. Can't correct for inlining.
MutationDetails [id=MutationIdentifier [location=Location [clazz=net.kautler.command.api.Version, method=<init>, methodDesc=()V], indexes=[61], mutator=org.pitest.mutationtest.engine.gregor.mutators.RemoveConditionalMutator_EQUAL_ELSE], filename=Version.java, block=13, lineNumber=81, description=removed conditional - replaced equality check with false, testsInOrder=[], isInFinallyBlock=true, poison=NORMAL]
MutationDetails [id=MutationIdentifier [location=Location [clazz=net.kautler.command.api.Version, method=<init>, methodDesc=()V], indexes=[63], mutator=org.pitest.mutationtest.engine.gregor.mutators.RemoveConditionalMutator_EQUAL_ELSE], filename=Version.java, block=14, lineNumber=81, description=removed conditional - replaced equality check with false, testsInOrder=[], isInFinallyBlock=true, poison=NORMAL]
09:45:53 PIT >> WARNING : Found more than one mutation similar on same line in a finally block. Can't correct for inlining.
MutationDetails [id=MutationIdentifier [location=Location [clazz=net.kautler.command.api.Version, method=<init>, methodDesc=()V], indexes=[61], mutator=org.pitest.mutationtest.engine.gregor.mutators.RemoveConditionalMutator_EQUAL_IF], filename=Version.java, block=13, lineNumber=81, description=removed conditional - replaced equality check with true, testsInOrder=[], isInFinallyBlock=true, poison=NORMAL]
MutationDetails [id=MutationIdentifier [location=Location [clazz=net.kautler.command.api.Version, method=<init>, methodDesc=()V], indexes=[63], mutator=org.pitest.mutationtest.engine.gregor.mutators.RemoveConditionalMutator_EQUAL_IF], filename=Version.java, block=14, lineNumber=81, description=removed conditional - replaced equality check with true, testsInOrder=[], isInFinallyBlock=true, poison=NORMAL]
09:45:53 PIT >> WARNING : Found more than one mutation similar on same line in a finally block. Can't correct for inlining.
MutationDetails [id=MutationIdentifier [location=Location [clazz=net.kautler.command.api.Version, method=<init>, methodDesc=()V], indexes=[61], mutator=org.pitest.mutationtest.engine.gregor.mutators.NegateConditionalsMutator], filename=Version.java, block=13, lineNumber=81, description=negated conditional, testsInOrder=[], isInFinallyBlock=true, poison=NORMAL]
MutationDetails [id=MutationIdentifier [location=Location [clazz=net.kautler.command.api.Version, method=<init>, methodDesc=()V], indexes=[63], mutator=org.pitest.mutationtest.engine.gregor.mutators.NegateConditionalsMutator], filename=Version.java, block=14, lineNumber=81, description=negated conditional, testsInOrder=[], isInFinallyBlock=true, poison=NORMAL]
@Vampire
Copy link
Contributor Author

Vampire commented Sep 26, 2019

Ah, the mutants themselves are actually later filtered out by the TryWithResourcesFilter.
So it would probably make sense to turn around the order so that the try-with-resources filter is done first?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant