Skip to content

Commit 9746bb4

Browse files
authored
allow java21 in jre matrix (#12281)
1 parent d9509b5 commit 9746bb4

File tree

12 files changed

+63
-34
lines changed

12 files changed

+63
-34
lines changed

.github/workflows/testing.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
runs-on: ubuntu-latest
1818
strategy:
1919
matrix:
20-
jre: [8, 11, 17]
20+
jre: [8, 11, 17, 21]
2121
fail-fast: false # Should swap to true if we grow a large matrix
2222

2323
steps:

api/src/main/java/io/grpc/StatusException.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@
2525
*/
2626
public class StatusException extends Exception {
2727
private static final long serialVersionUID = -660954903976144640L;
28+
@SuppressWarnings("serial") // https://github.com/grpc/grpc-java/issues/1913
2829
private final Status status;
30+
@SuppressWarnings("serial")
2931
private final Metadata trailers;
3032

3133
/**

api/src/main/java/io/grpc/StatusRuntimeException.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626
public class StatusRuntimeException extends RuntimeException {
2727

2828
private static final long serialVersionUID = 1950934672280720624L;
29+
@SuppressWarnings("serial") // https://github.com/grpc/grpc-java/issues/1913
2930
private final Status status;
31+
@SuppressWarnings("serial")
3032
private final Metadata trailers;
3133

3234
/**

core/src/main/java/io/grpc/internal/AbstractClientStream.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ void writeFrame(
101101
*/
102102
private volatile boolean cancelled;
103103

104+
@SuppressWarnings("this-escape")
104105
protected AbstractClientStream(
105106
WritableBufferAllocator bufferAllocator,
106107
StatsTraceContext statsTraceCtx,
@@ -113,7 +114,7 @@ protected AbstractClientStream(
113114
this.shouldBeCountedForInUse = GrpcUtil.shouldBeCountedForInUse(callOptions);
114115
this.useGet = useGet;
115116
if (!useGet) {
116-
framer = new MessageFramer(this, bufferAllocator, statsTraceCtx);
117+
this.framer = new MessageFramer(this, bufferAllocator, statsTraceCtx);
117118
this.headers = headers;
118119
} else {
119120
framer = new GetFramer(headers, statsTraceCtx);

core/src/main/java/io/grpc/internal/AbstractServerStream.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,11 @@ protected interface Sink {
7575
private boolean outboundClosed;
7676
private boolean headersSent;
7777

78+
@SuppressWarnings("this-escape")
7879
protected AbstractServerStream(
7980
WritableBufferAllocator bufferAllocator, StatsTraceContext statsTraceCtx) {
8081
this.statsTraceCtx = Preconditions.checkNotNull(statsTraceCtx, "statsTraceCtx");
81-
framer = new MessageFramer(this, bufferAllocator, statsTraceCtx);
82+
this.framer = new MessageFramer(this, bufferAllocator, statsTraceCtx);
8283
}
8384

8485
@Override

core/src/main/java/io/grpc/internal/AbstractStream.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,20 +163,21 @@ public abstract static class TransportState
163163
@GuardedBy("onReadyLock")
164164
private int onReadyThreshold;
165165

166+
@SuppressWarnings("this-escape")
166167
protected TransportState(
167168
int maxMessageSize,
168169
StatsTraceContext statsTraceCtx,
169170
TransportTracer transportTracer) {
170171
this.statsTraceCtx = checkNotNull(statsTraceCtx, "statsTraceCtx");
171172
this.transportTracer = checkNotNull(transportTracer, "transportTracer");
172-
rawDeframer = new MessageDeframer(
173+
this.rawDeframer = new MessageDeframer(
173174
this,
174175
Codec.Identity.NONE,
175176
maxMessageSize,
176177
statsTraceCtx,
177178
transportTracer);
178179
// TODO(#7168): use MigratingThreadDeframer when enabling retry doesn't break.
179-
deframer = rawDeframer;
180+
deframer = this.rawDeframer;
180181
onReadyThreshold = DEFAULT_ONREADY_THRESHOLD;
181182
}
182183

core/src/main/java/io/grpc/internal/JsonUtil.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ private static int parseNanos(String value) throws ParseException {
356356
return result;
357357
}
358358

359-
private static final long NANOS_PER_SECOND = TimeUnit.SECONDS.toNanos(1);
359+
private static final int NANOS_PER_SECOND = 1_000_000_000;
360360

361361
/**
362362
* Copy of {@link com.google.protobuf.util.Durations#normalizedDuration}.
@@ -368,11 +368,11 @@ private static long normalizedDuration(long seconds, int nanos) {
368368
nanos %= NANOS_PER_SECOND;
369369
}
370370
if (seconds > 0 && nanos < 0) {
371-
nanos += NANOS_PER_SECOND; // no overflow since nanos is negative (and we're adding)
371+
nanos += NANOS_PER_SECOND; // no overflow nanos is negative (and we're adding)
372372
seconds--; // no overflow since seconds is positive (and we're decrementing)
373373
}
374374
if (seconds < 0 && nanos > 0) {
375-
nanos -= NANOS_PER_SECOND; // no overflow since nanos is positive (and we're subtracting)
375+
nanos -= NANOS_PER_SECOND; // no overflow nanos is positive (and we're subtracting)
376376
seconds++; // no overflow since seconds is negative (and we're incrementing)
377377
}
378378
if (!durationIsValid(seconds, nanos)) {

inprocess/src/main/java/io/grpc/inprocess/AnonymousInProcessSocketAddress.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
import com.google.errorprone.annotations.concurrent.GuardedBy;
2222
import io.grpc.ExperimentalApi;
2323
import java.io.IOException;
24+
import java.io.NotSerializableException;
25+
import java.io.ObjectOutputStream;
2426
import java.net.SocketAddress;
2527
import javax.annotation.Nullable;
2628

@@ -34,8 +36,13 @@ public final class AnonymousInProcessSocketAddress extends SocketAddress {
3436

3537
@Nullable
3638
@GuardedBy("this")
39+
@SuppressWarnings("serial")
3740
private InProcessServer server;
3841

42+
private void writeObject(ObjectOutputStream out) throws IOException {
43+
throw new NotSerializableException("AnonymousInProcessSocketAddress is not serializable");
44+
}
45+
3946
/** Creates a new AnonymousInProcessSocketAddress. */
4047
public AnonymousInProcessSocketAddress() { }
4148

netty/src/main/java/io/grpc/netty/GrpcHttp2ConnectionHandler.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public abstract class GrpcHttp2ConnectionHandler extends Http2ConnectionHandler
6868
usingPre4_1_111_Netty = identifiedOldVersion;
6969
}
7070

71+
@SuppressWarnings("this-escape")
7172
protected GrpcHttp2ConnectionHandler(
7273
ChannelPromise channelUnused,
7374
Http2ConnectionDecoder decoder,

servlet/src/main/java/io/grpc/servlet/GrpcServlet.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
public class GrpcServlet extends HttpServlet {
3838
private static final long serialVersionUID = 1L;
3939

40+
@SuppressWarnings("serial")
4041
private final ServletAdapter servletAdapter;
4142

4243
GrpcServlet(ServletAdapter servletAdapter) {

0 commit comments

Comments
 (0)