Skip to content

Commit ba44d18

Browse files
committed
provides extra @NonNullApi annotation for all packages
Signed-off-by: Oleh Dokuka <[email protected]>
1 parent 79d2ee6 commit ba44d18

File tree

59 files changed

+196
-59
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+196
-59
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import io.netty.buffer.ByteBuf;
2020
import io.netty.util.AbstractReferenceCounted;
2121
import io.rsocket.core.DefaultConnectionSetupPayload;
22-
import javax.annotation.Nullable;
22+
import reactor.util.annotation.Nullable;
2323

2424
/**
2525
* Exposes information from the {@code SETUP} frame to a server, as well as to client responders.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@
4141
import java.util.function.BiConsumer;
4242
import java.util.function.Consumer;
4343
import java.util.function.Supplier;
44-
import javax.annotation.Nullable;
4544
import reactor.core.Disposable;
4645
import reactor.core.publisher.Mono;
4746
import reactor.core.scheduler.Schedulers;
47+
import reactor.util.annotation.Nullable;
4848
import reactor.util.retry.Retry;
4949

5050
/**

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
5656
import java.util.function.Consumer;
5757
import java.util.function.Supplier;
58-
import javax.annotation.Nullable;
5958
import org.reactivestreams.Processor;
6059
import org.reactivestreams.Publisher;
6160
import org.reactivestreams.Subscriber;
@@ -68,6 +67,7 @@
6867
import reactor.core.publisher.SignalType;
6968
import reactor.core.publisher.UnicastProcessor;
7069
import reactor.core.scheduler.Scheduler;
70+
import reactor.util.annotation.Nullable;
7171
import reactor.util.concurrent.Queues;
7272

7373
/**

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@
3939
import java.util.function.Consumer;
4040
import java.util.function.LongConsumer;
4141
import java.util.function.Supplier;
42-
import javax.annotation.Nullable;
4342
import org.reactivestreams.Processor;
4443
import org.reactivestreams.Publisher;
4544
import org.reactivestreams.Subscriber;
4645
import org.reactivestreams.Subscription;
4746
import reactor.core.Disposable;
4847
import reactor.core.Exceptions;
4948
import reactor.core.publisher.*;
49+
import reactor.util.annotation.Nullable;
5050
import reactor.util.concurrent.Queues;
5151

5252
/** Responder side of RSocket. Receives {@link ByteBuf}s from a peer's {@link RSocketRequester} */

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
package io.rsocket.core;
1717

1818
import io.netty.util.collection.IntObjectMap;
19+
import javax.annotation.concurrent.NotThreadSafe;
1920

21+
@NotThreadSafe
2022
final class StreamIdSupplier {
2123
private static final int MASK = 0x7FFFFFFF;
2224

rsocket-core/src/main/java/io/rsocket/exceptions/ApplicationErrorException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package io.rsocket.exceptions;
1818

1919
import io.rsocket.frame.ErrorFrameCodec;
20-
import javax.annotation.Nullable;
20+
import reactor.util.annotation.Nullable;
2121

2222
/**
2323
* Application layer logic generating a Reactive Streams {@code onError} event.

rsocket-core/src/main/java/io/rsocket/exceptions/CanceledException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package io.rsocket.exceptions;
1818

1919
import io.rsocket.frame.ErrorFrameCodec;
20-
import javax.annotation.Nullable;
20+
import reactor.util.annotation.Nullable;
2121

2222
/**
2323
* The Responder canceled the request but may have started processing it (similar to REJECTED but

rsocket-core/src/main/java/io/rsocket/exceptions/ConnectionCloseException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package io.rsocket.exceptions;
1818

1919
import io.rsocket.frame.ErrorFrameCodec;
20-
import javax.annotation.Nullable;
20+
import reactor.util.annotation.Nullable;
2121

2222
/**
2323
* The connection is being terminated. Sender or Receiver of this frame MUST wait for outstanding

rsocket-core/src/main/java/io/rsocket/exceptions/ConnectionErrorException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package io.rsocket.exceptions;
1818

1919
import io.rsocket.frame.ErrorFrameCodec;
20-
import javax.annotation.Nullable;
20+
import reactor.util.annotation.Nullable;
2121

2222
/**
2323
* The connection is being terminated. Sender or Receiver of this frame MAY close the connection

rsocket-core/src/main/java/io/rsocket/exceptions/CustomRSocketException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package io.rsocket.exceptions;
1818

1919
import io.rsocket.frame.ErrorFrameCodec;
20-
import javax.annotation.Nullable;
20+
import reactor.util.annotation.Nullable;
2121

2222
public class CustomRSocketException extends RSocketException {
2323
private static final long serialVersionUID = 7873267740343446585L;

rsocket-core/src/main/java/io/rsocket/exceptions/InvalidException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package io.rsocket.exceptions;
1818

1919
import io.rsocket.frame.ErrorFrameCodec;
20-
import javax.annotation.Nullable;
20+
import reactor.util.annotation.Nullable;
2121

2222
/**
2323
* The request is invalid.

rsocket-core/src/main/java/io/rsocket/exceptions/InvalidSetupException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package io.rsocket.exceptions;
1818

1919
import io.rsocket.frame.ErrorFrameCodec;
20-
import javax.annotation.Nullable;
20+
import reactor.util.annotation.Nullable;
2121

2222
/**
2323
* The Setup frame is invalid for the server (it could be that the client is too recent for the old

rsocket-core/src/main/java/io/rsocket/exceptions/RejectedException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package io.rsocket.exceptions;
1818

1919
import io.rsocket.frame.ErrorFrameCodec;
20-
import javax.annotation.Nullable;
20+
import reactor.util.annotation.Nullable;
2121

2222
/**
2323
* Despite being a valid request, the Responder decided to reject it. The Responder guarantees that

rsocket-core/src/main/java/io/rsocket/exceptions/RejectedResumeException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package io.rsocket.exceptions;
1818

1919
import io.rsocket.frame.ErrorFrameCodec;
20-
import javax.annotation.Nullable;
20+
import reactor.util.annotation.Nullable;
2121

2222
/**
2323
* The server rejected the resume, it can specify the reason in the payload.

rsocket-core/src/main/java/io/rsocket/exceptions/RejectedSetupException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package io.rsocket.exceptions;
1818

1919
import io.rsocket.frame.ErrorFrameCodec;
20-
import javax.annotation.Nullable;
20+
import reactor.util.annotation.Nullable;
2121

2222
/**
2323
* The server rejected the setup, it can specify the reason in the payload.

rsocket-core/src/main/java/io/rsocket/exceptions/SetupException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package io.rsocket.exceptions;
1818

1919
import io.rsocket.frame.ErrorFrameCodec;
20-
import javax.annotation.Nullable;
20+
import reactor.util.annotation.Nullable;
2121

2222
/** The root of the setup exception hierarchy. */
2323
public abstract class SetupException extends RSocketException {

rsocket-core/src/main/java/io/rsocket/exceptions/UnsupportedSetupException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package io.rsocket.exceptions;
1818

1919
import io.rsocket.frame.ErrorFrameCodec;
20-
import javax.annotation.Nullable;
20+
import reactor.util.annotation.Nullable;
2121

2222
/**
2323
* Some (or all) of the parameters specified by the client are unsupported by the server.

rsocket-core/src/main/java/io/rsocket/fragmentation/FragmentationDuplexConnection.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525
import io.rsocket.frame.FrameLengthCodec;
2626
import io.rsocket.frame.FrameType;
2727
import java.util.Objects;
28-
import javax.annotation.Nullable;
2928
import org.reactivestreams.Publisher;
3029
import org.slf4j.Logger;
3130
import org.slf4j.LoggerFactory;
3231
import reactor.core.publisher.Flux;
3332
import reactor.core.publisher.Mono;
33+
import reactor.util.annotation.Nullable;
3434

3535
/**
3636
* A {@link DuplexConnection} implementation that fragments and reassembles {@link ByteBuf}s.

rsocket-core/src/main/java/io/rsocket/fragmentation/FrameReassembler.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.slf4j.LoggerFactory;
3030
import reactor.core.Disposable;
3131
import reactor.core.publisher.SynchronousSink;
32+
import reactor.util.annotation.Nullable;
3233

3334
/**
3435
* The implementation of the RSocket reassembly behavior.
@@ -83,6 +84,7 @@ public boolean isDisposed() {
8384
return get();
8485
}
8586

87+
@Nullable
8688
synchronized ByteBuf getHeader(int streamId) {
8789
return headers.get(streamId);
8890
}
@@ -109,14 +111,17 @@ synchronized CompositeByteBuf getData(int streamId) {
109111
return byteBuf;
110112
}
111113

114+
@Nullable
112115
synchronized ByteBuf removeHeader(int streamId) {
113116
return headers.remove(streamId);
114117
}
115118

119+
@Nullable
116120
synchronized CompositeByteBuf removeMetadata(int streamId) {
117121
return metadata.remove(streamId);
118122
}
119123

124+
@Nullable
120125
synchronized CompositeByteBuf removeData(int streamId) {
121126
return data.remove(streamId);
122127
}
@@ -236,7 +241,6 @@ void reassembleFrame(ByteBuf frame, SynchronousSink<ByteBuf> sink) {
236241
case CANCEL:
237242
case ERROR:
238243
cancelAssemble(streamId);
239-
default:
240244
}
241245

242246
if (!frameType.isFragmentable()) {
@@ -270,7 +274,7 @@ private ByteBuf assembleFrameWithMetadata(ByteBuf frame, int streamId, ByteBuf h
270274
metadata = PayloadFrameCodec.metadata(frame).retain();
271275
}
272276
} else {
273-
metadata = cm != null ? cm : null;
277+
metadata = cm;
274278
}
275279

276280
ByteBuf data = assembleData(frame, streamId);

rsocket-core/src/main/java/io/rsocket/frame/ExtensionFrameCodec.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import io.netty.buffer.ByteBuf;
44
import io.netty.buffer.ByteBufAllocator;
5-
import javax.annotation.Nullable;
5+
import reactor.util.annotation.Nullable;
66

77
public class ExtensionFrameCodec {
88
private ExtensionFrameCodec() {}
@@ -49,6 +49,7 @@ public static ByteBuf data(ByteBuf byteBuf) {
4949
return data;
5050
}
5151

52+
@Nullable
5253
public static ByteBuf metadata(ByteBuf byteBuf) {
5354
FrameHeaderCodec.ensureFrameType(FrameType.EXT, byteBuf);
5455

rsocket-core/src/main/java/io/rsocket/frame/FrameBodyCodec.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import io.netty.buffer.ByteBuf;
44
import io.netty.buffer.ByteBufAllocator;
55
import io.netty.buffer.Unpooled;
6+
import reactor.util.annotation.Nullable;
67

78
class FrameBodyCodec {
89
public static final int FRAME_LENGTH_MASK = 0xFFFFFF;
@@ -33,9 +34,9 @@ private static int decodeLength(final ByteBuf byteBuf) {
3334
static ByteBuf encode(
3435
ByteBufAllocator allocator,
3536
final ByteBuf header,
36-
ByteBuf metadata,
37+
@Nullable ByteBuf metadata,
3738
boolean hasMetadata,
38-
ByteBuf data) {
39+
@Nullable ByteBuf data) {
3940

4041
final boolean addData;
4142
if (data != null) {

rsocket-core/src/main/java/io/rsocket/frame/GenericFrameCodec.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import io.netty.buffer.ByteBufAllocator;
55
import io.netty.util.IllegalReferenceCountException;
66
import io.rsocket.Payload;
7-
import javax.annotation.Nullable;
7+
import reactor.util.annotation.Nullable;
88

99
class GenericFrameCodec {
1010

@@ -75,7 +75,7 @@ static ByteBuf encode(
7575
boolean next,
7676
int requestN,
7777
@Nullable ByteBuf metadata,
78-
ByteBuf data) {
78+
@Nullable ByteBuf data) {
7979

8080
final boolean hasMetadata = metadata != null;
8181

@@ -115,6 +115,7 @@ static ByteBuf data(ByteBuf byteBuf) {
115115
return data;
116116
}
117117

118+
@Nullable
118119
static ByteBuf metadata(ByteBuf byteBuf) {
119120
boolean hasMetadata = FrameHeaderCodec.hasMetadata(byteBuf);
120121
if (!hasMetadata) {
@@ -136,6 +137,7 @@ static ByteBuf dataWithRequestN(ByteBuf byteBuf) {
136137
return data;
137138
}
138139

140+
@Nullable
139141
static ByteBuf metadataWithRequestN(ByteBuf byteBuf) {
140142
boolean hasMetadata = FrameHeaderCodec.hasMetadata(byteBuf);
141143
if (!hasMetadata) {

rsocket-core/src/main/java/io/rsocket/frame/LeaseFrameCodec.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
import io.netty.buffer.ByteBuf;
44
import io.netty.buffer.ByteBufAllocator;
5-
import io.netty.buffer.Unpooled;
6-
import javax.annotation.Nullable;
5+
import reactor.util.annotation.Nullable;
76

87
public class LeaseFrameCodec {
98

@@ -67,6 +66,7 @@ public static int numRequests(final ByteBuf byteBuf) {
6766
return numRequests;
6867
}
6968

69+
@Nullable
7070
public static ByteBuf metadata(final ByteBuf byteBuf) {
7171
FrameHeaderCodec.ensureFrameType(FrameType.LEASE, byteBuf);
7272
if (FrameHeaderCodec.hasMetadata(byteBuf)) {
@@ -77,7 +77,7 @@ public static ByteBuf metadata(final ByteBuf byteBuf) {
7777
byteBuf.resetReaderIndex();
7878
return metadata;
7979
} else {
80-
return Unpooled.EMPTY_BUFFER;
80+
return null;
8181
}
8282
}
8383
}

rsocket-core/src/main/java/io/rsocket/frame/MetadataPushFrameCodec.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
public class MetadataPushFrameCodec {
99

1010
public static ByteBuf encodeReleasingPayload(ByteBufAllocator allocator, Payload payload) {
11+
if (!payload.hasMetadata()) {
12+
throw new IllegalStateException(
13+
"Metadata push requires to have metadata present" + " in the given Payload");
14+
}
1115
final ByteBuf metadata = payload.metadata().retain();
1216
// releasing payload safely since it can be already released wheres we have to release retained
1317
// data and metadata as well

rsocket-core/src/main/java/io/rsocket/frame/PayloadFrameCodec.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import io.netty.buffer.ByteBuf;
44
import io.netty.buffer.ByteBufAllocator;
55
import io.rsocket.Payload;
6+
import reactor.util.annotation.Nullable;
67

78
public class PayloadFrameCodec {
89

@@ -37,8 +38,8 @@ public static ByteBuf encode(
3738
boolean fragmentFollows,
3839
boolean complete,
3940
boolean next,
40-
ByteBuf metadata,
41-
ByteBuf data) {
41+
@Nullable ByteBuf metadata,
42+
@Nullable ByteBuf data) {
4243

4344
return GenericFrameCodec.encode(
4445
allocator, FrameType.PAYLOAD, streamId, fragmentFollows, complete, next, 0, metadata, data);
@@ -48,6 +49,7 @@ public static ByteBuf data(ByteBuf byteBuf) {
4849
return GenericFrameCodec.data(byteBuf);
4950
}
5051

52+
@Nullable
5153
public static ByteBuf metadata(ByteBuf byteBuf) {
5254
return GenericFrameCodec.metadata(byteBuf);
5355
}

rsocket-core/src/main/java/io/rsocket/frame/RequestChannelFrameCodec.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import io.netty.buffer.ByteBuf;
44
import io.netty.buffer.ByteBufAllocator;
55
import io.rsocket.Payload;
6+
import reactor.util.annotation.Nullable;
67

78
public class RequestChannelFrameCodec {
89

@@ -31,7 +32,7 @@ public static ByteBuf encode(
3132
boolean fragmentFollows,
3233
boolean complete,
3334
long initialRequestN,
34-
ByteBuf metadata,
35+
@Nullable ByteBuf metadata,
3536
ByteBuf data) {
3637

3738
if (initialRequestN < 1) {
@@ -56,6 +57,7 @@ public static ByteBuf data(ByteBuf byteBuf) {
5657
return GenericFrameCodec.dataWithRequestN(byteBuf);
5758
}
5859

60+
@Nullable
5961
public static ByteBuf metadata(ByteBuf byteBuf) {
6062
return GenericFrameCodec.metadataWithRequestN(byteBuf);
6163
}

0 commit comments

Comments
 (0)