Skip to content

Commit

Permalink
#819 review fix
Browse files Browse the repository at this point in the history
  • Loading branch information
olenagerasimova committed Nov 15, 2018
1 parent 5adae2e commit f342d16
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/main/java/org/takes/facets/hamcrest/AbstractHmTextBody.java
Expand Up @@ -54,11 +54,6 @@ public abstract class AbstractHmTextBody<T> extends TypeSafeMatcher<T> {
*/
private final Charset charset;

/**
* Text from item for mismatch description.
*/
private String itext;

/**
* Ctor.
* @param body Body matcher.
Expand All @@ -79,8 +74,7 @@ public final void describeTo(final Description description) {
@Override
protected final boolean matchesSafely(final T item) {
try {
this.itext = this.text(item);
return this.body.matches(this.itext);
return this.body.matches(this.text(item));
} catch (final IOException ex) {
throw new IllegalStateException(ex);
}
Expand All @@ -89,7 +83,11 @@ protected final boolean matchesSafely(final T item) {
@Override
protected final void describeMismatchSafely(final T item, final
Description description) {
description.appendText("body was: ").appendText(this.itext);
try {
description.appendText("body was: ").appendText(this.text(item));
} catch (final IOException ex) {
throw new IllegalStateException(ex);
}
}

/**
Expand Down

0 comments on commit f342d16

Please sign in to comment.