-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c9e4b58
commit 6a38253
Showing
3 changed files
with
37 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package mina.core; | ||
|
||
import java.io.PrintWriter; | ||
import java.io.StringWriter; | ||
import java.text.MessageFormat; | ||
import java.util.Arrays; | ||
import java.util.stream.Collectors; | ||
|
||
public class ForbiddenCheck implements MinaCheck { | ||
private final MinaCondition condition; | ||
|
||
public ForbiddenCheck(MinaCondition condition) { | ||
this.condition = condition; | ||
} | ||
|
||
@Override | ||
public void verify(int index, Object[] arguments, Throwable throwable) { | ||
StringWriter stringWriter = new StringWriter(); | ||
PrintWriter writer = new PrintWriter(stringWriter); | ||
writer.println(MessageFormat.format("A forbidden log was caught on condition [{0}].", condition)); | ||
if (arguments != null) { | ||
writer.println( | ||
MessageFormat.format( | ||
"arguments = [{0}]", | ||
Arrays.stream(arguments).map(String::valueOf).collect(Collectors.joining(",")) | ||
) | ||
); | ||
} | ||
if (throwable != null) { | ||
writer.print("Exception: "); | ||
writer.println(throwable.getMessage()); | ||
throwable.printStackTrace(writer); | ||
} | ||
throw new AssertionError(stringWriter.toString()); | ||
} | ||
} |