File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77
88import javax .annotation .WillCloseWhenClosed ;
99
10- import com .google .common .base .Throwables ;
11-
1210final class AutoCloseableHtmlStreamRenderer extends HtmlStreamRenderer
1311 // This is available on JDK6 and makes this class extend AutoCloseable.
1412 implements Closeable {
@@ -83,8 +81,10 @@ static void closeIfAnyCloseable(Object closeable) throws IOException {
8381 Throwable tgt = ex .getTargetException ();
8482 if (tgt instanceof IOException ) {
8583 throw (IOException ) tgt ;
84+ } else if (tgt instanceof RuntimeException ) {
85+ throw (RuntimeException ) tgt ;
8686 } else {
87- Throwables . propagate ( tgt );
87+ throw new AssertionError ( null , tgt );
8888 }
8989 }
9090 }
Original file line number Diff line number Diff line change 2828
2929package org .owasp .html ;
3030
31- import com .google .common .base .Throwables ;
32-
3331/**
3432 * Receives notification of problems.
3533 *
@@ -57,7 +55,11 @@ public void handle(Object x) {
5755 */
5856 public static final Handler <Throwable > PROPAGATE = new Handler <Throwable >() {
5957 public void handle (Throwable th ) {
60- Throwables .propagate (th );
58+ if (th instanceof RuntimeException ) {
59+ throw (RuntimeException ) th ;
60+ } else {
61+ throw new AssertionError (null , th );
62+ }
6163 }
6264 };
6365}
Original file line number Diff line number Diff line change 4040
4141import com .google .common .base .Charsets ;
4242import com .google .common .base .Predicate ;
43- import com .google .common .base .Throwables ;
4443import com .google .common .io .CharStreams ;
4544
4645/**
@@ -217,7 +216,8 @@ public static void main(String[] args) throws IOException {
217216 // Receives notifications on a failure to write to the output.
218217 new Handler <IOException >() {
219218 public void handle (IOException ex ) {
220- Throwables .propagate (ex ); // System.out suppresses IOExceptions
219+ // System.out suppresses IOExceptions
220+ throw new AssertionError (null , ex );
221221 }
222222 },
223223 // Our HTML parser is very lenient, but this receives notifications on
@@ -242,7 +242,7 @@ public boolean apply(String s) {
242242 // java.util.function.Predicate.
243243 // For some reason the default test method implementation that calls
244244 // through to apply is not assumed here.
245- @ SuppressWarnings ("unused " )
245+ @ SuppressWarnings ("all " )
246246 public boolean test (String s ) {
247247 return apply (s );
248248 }
Original file line number Diff line number Diff line change 4040
4141import com .google .common .base .Charsets ;
4242import com .google .common .base .Function ;
43- import com .google .common .base .Throwables ;
4443import com .google .common .io .CharStreams ;
4544
4645/**
@@ -108,7 +107,8 @@ public static void main(String[] args) throws IOException {
108107 // Receives notifications on a failure to write to the output.
109108 new Handler <IOException >() {
110109 public void handle (IOException ex ) {
111- Throwables .propagate (ex ); // System.out suppresses IOExceptions
110+ // System.out suppresses IOExceptions
111+ throw new AssertionError (null , ex );
112112 }
113113 },
114114 // Our HTML parser is very lenient, but this receives notifications on
Original file line number Diff line number Diff line change @@ -59,7 +59,7 @@ public class Benchmark {
5959 * specifies a benchmark to run and unspecified ones are not run.
6060 */
6161 public static void main (String [] args ) throws Exception {
62- String html = Files .toString (new File (args [0 ]), Charsets .UTF_8 );
62+ String html = Files .asCharSource (new File (args [0 ]), Charsets .UTF_8 ). read ( );
6363
6464 boolean timeLibhtmlparser = true ;
6565 boolean timeSanitize = true ;
Original file line number Diff line number Diff line change 3434import java .io .PrintStream ;
3535import java .lang .reflect .Method ;
3636
37- import com .google .common .base .Throwables ;
38-
3937import org .junit .Test ;
4038import org .owasp .html .examples .EbayPolicyExample ;
4139
@@ -66,7 +64,11 @@ public static final void testExamplesRun() throws Exception {
6664 System .err .println (
6765 "Example " + exampleClass .getSimpleName () + "\n "
6866 + captured .toString ("UTF-8" ));
69- Throwables .propagate (ex );
67+ if (ex instanceof RuntimeException ) {
68+ throw (RuntimeException ) ex ;
69+ } else {
70+ throw new AssertionError (null , ex );
71+ }
7072 } finally {
7173 System .setIn (stdin );
7274 System .setOut (stdout );
Original file line number Diff line number Diff line change 3434import java .util .concurrent .TimeUnit ;
3535
3636import com .google .common .base .Charsets ;
37- import com .google .common .base .Throwables ;
3837import com .google .common .io .Resources ;
3938
4039/**
@@ -144,7 +143,11 @@ public void run() {
144143 assertTrue ("seed=" + seed , executor .isTerminated ());
145144 Throwable failure = failures .poll ();
146145 if (failure != null ) {
147- Throwables .propagate (failure );
146+ if (failure instanceof RuntimeException ) {
147+ throw (RuntimeException ) failure ;
148+ } else {
149+ throw new AssertionError (null , failure );
150+ }
148151 }
149152 }
150153
You can’t perform that action at this time.
0 commit comments