Skip to content

Commit b330634

Browse files
committed
Turn off suppressed exceptions (to squash)
Signed-off-by: Rossen Stoyanchev <[email protected]> Use static errors in default RSocket methods Closes gh-865 Signed-off-by: Rossen Stoyanchev <[email protected]>
1 parent b5952f6 commit b330634

File tree

2 files changed

+84
-10
lines changed

2 files changed

+84
-10
lines changed

rsocket-core/src/main/java/io/rsocket/RSocket.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2018 the original author or authors.
2+
* Copyright 2015-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -34,8 +34,7 @@ public interface RSocket extends Availability, Closeable {
3434
* handled, otherwise errors.
3535
*/
3636
default Mono<Void> fireAndForget(Payload payload) {
37-
payload.release();
38-
return Mono.error(new UnsupportedOperationException("Fire-and-Forget not implemented."));
37+
return RSocketAdapter.fireAndForget(payload);
3938
}
4039

4140
/**
@@ -46,8 +45,7 @@ default Mono<Void> fireAndForget(Payload payload) {
4645
* response.
4746
*/
4847
default Mono<Payload> requestResponse(Payload payload) {
49-
payload.release();
50-
return Mono.error(new UnsupportedOperationException("Request-Response not implemented."));
48+
return RSocketAdapter.requestResponse(payload);
5149
}
5250

5351
/**
@@ -57,8 +55,7 @@ default Mono<Payload> requestResponse(Payload payload) {
5755
* @return {@code Publisher} containing the stream of {@code Payload}s representing the response.
5856
*/
5957
default Flux<Payload> requestStream(Payload payload) {
60-
payload.release();
61-
return Flux.error(new UnsupportedOperationException("Request-Stream not implemented."));
58+
return RSocketAdapter.requestStream(payload);
6259
}
6360

6461
/**
@@ -68,7 +65,7 @@ default Flux<Payload> requestStream(Payload payload) {
6865
* @return Stream of response payloads.
6966
*/
7067
default Flux<Payload> requestChannel(Publisher<Payload> payloads) {
71-
return Flux.error(new UnsupportedOperationException("Request-Channel not implemented."));
68+
return RSocketAdapter.requestChannel(payloads);
7269
}
7370

7471
/**
@@ -79,8 +76,7 @@ default Flux<Payload> requestChannel(Publisher<Payload> payloads) {
7976
* handled, otherwise errors.
8077
*/
8178
default Mono<Void> metadataPush(Payload payload) {
82-
payload.release();
83-
return Mono.error(new UnsupportedOperationException("Metadata-Push not implemented."));
79+
return RSocketAdapter.metadataPush(payload);
8480
}
8581

8682
@Override
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/*
2+
* Copyright 2015-2020 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package io.rsocket;
18+
19+
import org.reactivestreams.Publisher;
20+
import reactor.core.publisher.Flux;
21+
import reactor.core.publisher.Mono;
22+
23+
/**
24+
* Package private class with default implementations for use in {@link RSocket}. The main purpose
25+
* is to hide static {@link UnsupportedOperationException} declarations.
26+
*
27+
* @since 1.0.3
28+
*/
29+
class RSocketAdapter {
30+
31+
private static final Mono<Void> UNSUPPORTED_FIRE_AND_FORGET =
32+
Mono.error(new UnsupportedInteractionException("Fire-and-Forget"));
33+
34+
private static final Mono<Payload> UNSUPPORTED_REQUEST_RESPONSE =
35+
Mono.error(new UnsupportedInteractionException("Request-Response"));
36+
37+
private static final Flux<Payload> UNSUPPORTED_REQUEST_STREAM =
38+
Flux.error(new UnsupportedInteractionException("Request-Stream"));
39+
40+
private static final Flux<Payload> UNSUPPORTED_REQUEST_CHANNEL =
41+
Flux.error(new UnsupportedInteractionException("Request-Channel"));
42+
43+
private static final Mono<Void> UNSUPPORTED_METADATA_PUSH =
44+
Mono.error(new UnsupportedInteractionException("Metadata-Push"));
45+
46+
static Mono<Void> fireAndForget(Payload payload) {
47+
payload.release();
48+
return RSocketAdapter.UNSUPPORTED_FIRE_AND_FORGET;
49+
}
50+
51+
static Mono<Payload> requestResponse(Payload payload) {
52+
payload.release();
53+
return RSocketAdapter.UNSUPPORTED_REQUEST_RESPONSE;
54+
}
55+
56+
static Flux<Payload> requestStream(Payload payload) {
57+
payload.release();
58+
return RSocketAdapter.UNSUPPORTED_REQUEST_STREAM;
59+
}
60+
61+
static Flux<Payload> requestChannel(Publisher<Payload> payloads) {
62+
return RSocketAdapter.UNSUPPORTED_REQUEST_CHANNEL;
63+
}
64+
65+
static Mono<Void> metadataPush(Payload payload) {
66+
payload.release();
67+
return RSocketAdapter.UNSUPPORTED_METADATA_PUSH;
68+
}
69+
70+
private static class UnsupportedInteractionException extends RuntimeException {
71+
72+
private static final long serialVersionUID = 5084623297446471999L;
73+
74+
UnsupportedInteractionException(String interactionName) {
75+
super(interactionName + " not implemented.", null, false, false);
76+
}
77+
}
78+
}

0 commit comments

Comments
 (0)