Skip to content

Commit 930400a

Browse files
SLF4J Cleanup
CompositeLogScrubber ctr arg guards & test. Added documentation.
1 parent 60d2350 commit 930400a

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

src/main/java/org/owasp/esapi/logging/cleaning/CompositeLogScrubber.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,26 @@
1717
import java.util.ArrayList;
1818
import java.util.List;
1919

20+
/**
21+
* LogScrubber implementation which performs iterative delegate to an ordered
22+
* List of LogScrubbers. <br>
23+
* The results of the delegate list of LogScrubbers is additive, meaning that
24+
* the the original message is passed to the first delegate and its return value
25+
* is passed to the second (etc). <br>
26+
*
27+
*/
2028
public class CompositeLogScrubber implements LogScrubber {
21-
29+
/** Delegate scrubbers.*/
2230
private final List<LogScrubber> messageCleaners;
2331

32+
/**
33+
* Ctr.
34+
* @param orderedCleaner Ordered List of delegate implementations. Cannot be {@code null}
35+
*/
2436
public CompositeLogScrubber(List<LogScrubber> orderedCleaner) {
37+
if (orderedCleaner == null) {
38+
throw new IllegalArgumentException ("Delegate LogScrubber List cannot be null");
39+
}
2540
this.messageCleaners = new ArrayList<>(orderedCleaner);
2641
}
2742

src/test/java/org/owasp/esapi/logging/cleaning/CompositeLogScrubberTest.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,26 @@
1818
import java.util.Arrays;
1919

2020
import org.junit.Assert;
21+
import org.junit.Rule;
2122
import org.junit.Test;
23+
import org.junit.rules.ExpectedException;
2224
import org.mockito.Mockito;
2325

2426

2527
public class CompositeLogScrubberTest {
2628

29+
@Rule
30+
public ExpectedException exEx = ExpectedException.none();
31+
32+
@Test
33+
public void testNullListThrowsException() {
34+
exEx.expect(IllegalArgumentException.class);
35+
exEx.expectMessage("cannot be null");
36+
37+
new CompositeLogScrubber(null);
38+
}
39+
40+
2741
@Test
2842
public void testPassthroughOnEmpty() {
2943
String str = "Testing Content";

0 commit comments

Comments
 (0)