Skip to content

Commit

Permalink
fix sonar complaints; #20
Browse files Browse the repository at this point in the history
  • Loading branch information
bbilger committed Jun 21, 2017
1 parent e146708 commit ffda9da
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import java.io.IOException;
import java.util.Base64;

import javax.ws.rs.WebApplicationException;
import javax.ws.rs.ext.ReaderInterceptor;
import javax.ws.rs.ext.ReaderInterceptorContext;

Expand All @@ -33,7 +32,7 @@
public abstract class ConditionalBase64ReadInterceptor implements ReaderInterceptor {

@Override
public final Object aroundReadFrom(ReaderInterceptorContext context) throws IOException, WebApplicationException {
public final Object aroundReadFrom(ReaderInterceptorContext context) throws IOException {
if (isBase64(context)) {
context.setInputStream(Base64.getDecoder().wrap(context.getInputStream()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,10 @@ public class DynamicJerseyTestRunner {
*/
public void runJerseyTest(JerseyTest jerseyTest, ThrowingConsumer<JerseyTest> test) throws Exception {
try {
try {
jerseyTest.setUp();
} catch (Exception e) {
throw new RuntimeException(e);
}
jerseyTest.setUp();
test.accept(jerseyTest);
} finally {
try {
jerseyTest.tearDown();
} catch (Exception e) {
throw new RuntimeException(e);
}
jerseyTest.tearDown();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static byte[] toBytes(InputStream is) {
buffer.flush();
return buffer.toByteArray();
} catch (IOException ioe) {
throw new RuntimeException(ioe);
throw new IORuntimeException(ioe);
}
}

Expand Down Expand Up @@ -85,4 +85,11 @@ public static String toString(InputStream is, Charset charset) {
return new String(toBytes(is), charset);
}

public static final class IORuntimeException extends RuntimeException {
private static final long serialVersionUID = 1L;
private IORuntimeException(IOException ioe) {
super(ioe);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,15 @@ public static <T> void invokePrivateConstructor(Class<T> clazz) {
constructor.newInstance();
} catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException
| IllegalArgumentException | InvocationTargetException e) {
throw new RuntimeException(e);
throw new ConstructorInvocationException(e);
}
}

public static final class ConstructorInvocationException extends RuntimeException {
private static final long serialVersionUID = 1L;
private ConstructorInvocationException(Exception e) {
super(e);
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void testRethrowsExceptionOnStartupFailure() throws Exception {
runner.runJerseyTest(jerseyTest, consumer);
fail("expected exception to be thrown");
} catch (RuntimeException re) {
assertSame(thrownException, re.getCause());
assertSame(thrownException, re);
}
}

Expand All @@ -64,7 +64,7 @@ public void testRethrowsExceptionOnTearDownFailure() throws Exception {
runner.runJerseyTest(jerseyTest, consumer);
fail("expected exception to be thrown");
} catch (RuntimeException re) {
assertSame(thrownException, re.getCause());
assertSame(thrownException, re);
}
}

Expand Down Expand Up @@ -117,7 +117,7 @@ public void testRethrowsTearDownExceptionOnConsumerAndTearDownFailure() throws E
runner.runJerseyTest(jerseyTest, consumer);
fail("expected exception to be thrown");
} catch (Exception e) {
assertSame(tearDownException, e.getCause());
assertSame(tearDownException, e);
}
}
}

0 comments on commit ffda9da

Please sign in to comment.