8000 remove redundant throws clauses by qweek · Pull Request #386 · rsocket/rsocket-java · GitHub
[go: up one dir, main page]

Skip to content

remove redundant throws clauses #386

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 14, 2017
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ subprojects {
compileJava {
sourceCompatibility = 1.8
targetCompatibility = 1.8
options.compilerArgs << "-Xlint:deprecation" // << "-Xlint:unchecked"
}

ext {
Expand Down
1 change: 0 additions & 1 deletion rsocket-core/src/main/java/io/rsocket/RSocketClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,6 @@ private void handleStreamZero(FrameType type, Frame frame) {
}
}

@SuppressWarnings("unchecked")
private void handleFrame(int streamId, FrameType type, Frame frame) {
Subscriber<Payload> receiver;
synchronized (this) {
Expand Down
18 changes: 9 additions & 9 deletions rsocket-core/src/test/java/io/rsocket/RSocketClientTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
import static org.mockito.Matchers.any;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.verify;

import io.rsocket.exceptions.ApplicationException;
Expand Down Expand Up @@ -57,7 +57,7 @@ public void testKeepAlive() throws Exception {
}

@Test(timeout = 2_000)
public void testInvalidFrameOnStream0() throws Throwable {
public void testInvalidFrameOnStream0() {
rule.connection.addToReceivedBuffer(Frame.RequestN.from(0, 10));
assertThat("Unexpected errors.", rule.errors, hasSize(1));
assertThat(
Expand All @@ -67,7 +67,7 @@ public void testInvalidFrameOnStream0() throws Throwable {
}

@Test(timeout = 2_000)
public void testStreamInitialN() throws InterruptedException {
public void testStreamInitialN() {
Flux<Payload> stream = rule.socket.requestStream(PayloadImpl.EMPTY);

BaseSubscriber<Payload> subscriber =
Expand Down Expand Up @@ -98,7 +98,7 @@ protected void hookOnSubscribe(Subscription subscription) {
}

@Test(timeout = 2_000)
public void testHandleSetupException() throws Throwable {
public void testHandleSetupException() {
rule.connection.addToReceivedBuffer(Frame.Error.from(0, new RejectedSetupException("boom")));
assertThat("Unexpected errors.", rule.errors, hasSize(1));
assertThat(
Expand All @@ -108,7 +108,7 @@ public void testHandleSetupException() throws Throwable {
}

@Test(timeout = 2_000)
public void testHandleApplicationException() throws Throwable {
public void testHandleApplicationException() {
rule.connection.clearSendReceiveBuffers();
Publisher<Payload> response = rule.socket.requestResponse(PayloadImpl.EMPTY);
Subscriber<Payload> responseSub = TestSubscriber.create();
Expand All @@ -122,7 +122,7 @@ public void testHandleApplicationException() throws Throwable {
}

@Test(timeout = 2_000)
public void testHandleValidFrame() throws Throwable {
public void testHandleValidFrame() {
Publisher<Payload> response = rule.socket.requestResponse(PayloadImpl.EMPTY);
Subscriber<Payload> sub = TestSubscriber.create();
response.subscribe(sub);
Expand All @@ -136,7 +136,7 @@ public void testHandleValidFrame() throws Throwable {
}

@Test(timeout = 2_000)
public void testRequestReplyWithCancel() throws Throwable {
public void testRequestReplyWithCancel() {
Mono<Payload> response = rule.socket.requestResponse(PayloadImpl.EMPTY);

try {
Expand All @@ -157,7 +157,7 @@ public void testRequestReplyWithCancel() throws Throwable {
}

@Test(timeout = 2_000)
public void testRequestReplyErrorOnSend() throws Throwable {
public void testRequestReplyErrorOnSend() {
rule.connection.setAvailability(0); // Fails send
Mono<Payload> response = rule.socket.requestResponse(PayloadImpl.EMPTY);
Subscriber<Payload> responseSub = TestSubscriber.create();
Expand All @@ -167,7 +167,7 @@ public void testRequestReplyErrorOnSend() throws Throwable {
}

@Test
public void testLazyRequestResponse() throws Exception {
public void testLazyRequestResponse() {
Publisher<Payload> response = rule.socket.requestResponse(PayloadImpl.EMPTY);
int streamId = sendRequestResponse(response);
rule.connection.clearSendReceiveBuffers();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void testHandlerEmitsError() throws Exception {
}

@Test(timeout = 2_0000)
public void testCancel() throws Exception {
public void testCancel() {
final int streamId = 4;
final AtomicBoolean cancelled = new AtomicBoolean();
rule.setAcceptingSocket(
Expand Down
2 changes: 1 addition & 1 deletion rsocket-core/src/test/java/io/rsocket/RSocketTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.is;
import static org.mockito.Matchers.any;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.verify;

import io.rsocket.exceptions.ApplicationException;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.rsocket.test.util;

import static org.mockito.Matchers.any;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;

import io.rsocket.Payload;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ public class PayloadImplTest {
public static final String METADATA_VAL = "metadata";

@Test
public void testReuse() throws Exception {
public void testReuse() {
PayloadImpl p = new PayloadImpl(DATA_VAL, METADATA_VAL);
assertDataAndMetadata(p, DATA_VAL, METADATA_VAL);
assertDataAndMetadata(p, DATA_VAL, METADATA_VAL);
}

@Test
public void testReuseWithExternalMark() throws Exception {
public void testReuseWithExternalMark() {
PayloadImpl p = new PayloadImpl(DATA_VAL, METADATA_VAL);
assertDataAndMetadata(p, DATA_VAL, METADATA_VAL);
p.getData().position(2).mark();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.any;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;

Expand All @@ -36,8 +36,6 @@
import io.rsocket.util.PayloadImpl;
import io.rsocket.util.RSocketProxy;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicInteger;
import org.junit.After;
import org.junit.Before;
Expand Down Expand Up @@ -148,16 +146,16 @@ public void testRequest() {
}

@Test
public void testStream() throws Exception {
Subscriber subscriber = TestSubscriber.createCancelling();
public void testStream() {
Subscriber<Payload> subscriber = TestSubscriber.createCancelling();
client.requestStream(new PayloadImpl("start")).subscribe(subscriber);

verify(subscriber).onSubscribe(any());
verifyNoMoreInteractions(subscriber);
}

@Test(timeout = 5_000L)
public void testClose() throws ExecutionException, InterruptedException, TimeoutException {
public void testClose() throws InterruptedException {
client.close().block();
disconnectionCounter.await();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void cleanup() {
}

@Test(timeout = 5_000L)
public void testCompleteWithoutNext() throws InterruptedException {
public void testCompleteWithoutNext() {
handler =
new AbstractRSocket() {
@Override
Expand All @@ -83,7 +83,7 @@ public Flux<Payload> requestStream(Payload payload) {
}

@Test(timeout = 5_000L)
public void testSingleStream() throws InterruptedException {
public void testSingleStream() {
handler =
new AbstractRSocket() {
@Override
Expand All @@ -100,7 +100,7 @@ public Flux<Payload> requestStream(Payload payload) {
}

@Test(timeout = 5_000L)
public void testZeroPayload() throws InterruptedException {
public void testZeroPayload() {
handler =
new AbstractRSocket() {
@Override
Expand All @@ -117,7 +117,7 @@ public Flux<Payload> requestStream(Payload payload) {
}

@Test(timeout = 5_000L)
public void testRequestResponseErrors() throws InterruptedException {
public void testRequestResponseErrors() {
handler =
new AbstractRSocket() {
boolean first = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@

public interface Quantile {
/** @return the estimation of the current value of the quantile */
public double estimation();
double estimation();

/**
* Insert a data point `x` in the quantile estimator.
*
* @param x the data point to add.
*/
public void insert(double x);
void insert(double x);
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.Matchers.any;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.verify;

import io.rsocket.Payload;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import com.netflix.spectator.api.Timer;
import io.rsocket.Payload;
import io.rsocket.RSocket;
import java.lang.reflect.Array;
import java.util.concurrent.TimeUnit;
import org.reactivestreams.Publisher;
import reactor.core.publisher.Flux;
Expand Down Expand Up @@ -99,16 +98,15 @@ public SpectatorRSocket(Registry registry, RSocket delegate, String... tags) {
registry.timer("reactiveSocketStats", concatenate(tags, "metadataPush", "timer"));
}

static <T> T[] concatenate(T[] a, T... b) {
private static String[] concatenate(String[] a, String... b) {
if (a == null || a.length == 0) {
return b;
}

int aLen = a.length;
int bLen = b.length;

@SuppressWarnings("unchecked")
T[] c = (T[]) Array.newInstance(a.getClass().getComponentType(), aLen + bLen);
String[] c = new String[aLen + bLen];
System.arraycopy(a, 0, c, 0, aLen);
System.arraycopy(b, 0, c, aLen, bLen);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

import static org.junit.Assert.*;

import com.google.common.base.Throwables;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
Expand Down Expand Up @@ -64,7 +63,7 @@ public JavaClientDriver(Mono<RSocket> clientBuilder) {
.build(
new CacheLoader<String, RSocket>() {
@Override
public RSocket load(String key) throws Exception {
public RSocket load(String key) {
return clientBuilder.block();
}
});
Expand Down Expand Up @@ -169,7 +168,7 @@ private RSocket getClient(String id) {
try {
return clientMap.get(id);
} catch (ExecutionException e) {
throw Throwables.propagate(e);
throw new RuntimeException(e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

import static java.util.stream.Collectors.toList;

import com.google.common.base.Throwables;
import com.google.common.io.Files;
import java.io.File;
import java.io.IOException;
Expand Down Expand Up @@ -43,7 +42,7 @@ public static List<TckClientTest> extractTests(File file) {
.map(testLines -> new TckClientTest(parseName(testLines.remove(0)), testLines))
.collect(toList());
} catch (IOException e) {
throw Throwables.propagate(e);
throw new RuntimeException(e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import static java.util.stream.Collectors.toList;

import com.google.common.base.Throwables;
import com.google.common.io.Files;
import io.rsocket.tckdrivers.server.JavaServerDriver;
import java.io.File;
Expand Down Expand Up @@ -54,7 +53,7 @@ private static TckTestSuite extractTests(File serverFile) {

return tckTestSuite;
} catch (IOException e) {
throw Throwables.propagate(e);
throw new RuntimeException(e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,8 @@ public class Main {
* @param host client connects with this host
* @param port client connects on this port
* @param testFilter predicate for tests to run
* @throws Exception if an exception occurs
*/
public static void runTests(String host, int port, Predicate<String> testFilter)
throws Exception {
public static void runTests(String host, int port, Predicate<String> testFilter) {
TcpClientTransport transport = TcpClientTransport.create(host, port);
Mono<RSocket> clientBuilder = RSocketFactory.connect().transport(transport).start();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.base.Throwables;
import io.rsocket.Payload;
import java.io.IOException;
import java.util.Map;
Expand All @@ -20,7 +19,7 @@ public static Map<String, Object> parseTCKMessage(Payload content, String messag
content.getDataUtf8(), new TypeReference<Map<String, Map<String, Object>>>() {});
return message.get(messageType);
} catch (IOException e) {
throw Throwables.propagate(e);
throw new RuntimeException(e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@ public RunnerRSocket() {}
@Override
public Mono<Payload> requestResponse(Payload payload) {
Map<String, Object> clientTest = parseTCKMessage(payload, "runnerExecuteTest");
@SuppressWarnings("unchecked")
Map<String, Object> setup = (Map<String, Object>) clientTest.get("setup");
@SuppressWarnings("unchecked")
Map<String, Object> test = (Map<String, Object>) clientTest.get("test");
@SuppressWarnings("unchecked")
Map<String, Object> tck1Definition = (Map<String, Object>) test.get("tck1Definition");

String url = (String) setup.get("url");
Expand Down Expand Up @@ -68,8 +71,11 @@ public Mono<Payload> requestResponse(Payload payload) {
public Flux<Payload> requestStream(Payload payload) {
Map<String, Object> serverTest = parseTCKMessage(payload, "runnerExecuteTest");

@SuppressWarnings("unchecked")
Map<String, Object> setup = (Map<String, Object>) serverTest.get("setup");
@SuppressWarnings("unchecked")
Map<String, Object> test = (Map<String, Object>) serverTest.get("test");
@SuppressWarnings("unchecked")
Map<String, Object> tck1Definition = (Map<String, Object>) test.get("tck1Definition");

// TODO check version
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ public static String result(Map<String, Object> t) {
}

public static void printTestRunResults(Map<String, Object> suite) {
@SuppressWarnings("unchecked")
Map<String, Object> setup = (Map<String, Object>) suite.get("setup");
@SuppressWarnings("unchecked")
List<Map<String, Object>> tests = (List<Map<String, Object>>) suite.get("tests");

for (Map<String, Object> t : tests) {
Expand Down
Loading
0