Skip to content

Commit 1ee21f3

Browse files
committed
fix: format and BinderServerBuilder
1 parent a8b66f4 commit 1ee21f3

4 files changed

Lines changed: 15 additions & 22 deletions

File tree

binder/src/main/java/io/grpc/binder/BinderServerBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ private BinderServerBuilder(
6868

6969
serverImplBuilder =
7070
new ServerImplBuilder(
71-
streamTracerFactories -> {
71+
(streamTracerFactories, metricRecorder) -> {
7272
internalBuilder.setStreamTracerFactories(streamTracerFactories);
7373
BinderServer server = internalBuilder.build();
7474
BinderInternal.setIBinder(binderReceiver, server.getHostBinder());

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ public interface InternalServer {
5858
/**
5959
* Returns the first listen socket stats of this server. May return {@code null}.
6060
*/
61-
@Nullable
62-
InternalInstrumented<SocketStats> getListenSocketStats();
61+
@Nullable InternalInstrumented<SocketStats> getListenSocketStats();
6362

6463
/**
6564
* Returns a list of listening socket addresses. May change after {@link #start(ServerListener)}
@@ -70,7 +69,6 @@ public interface InternalServer {
7069
/**
7170
* Returns a list of listen socket stats of this server. May return {@code null}.
7271
*/
73-
@Nullable
74-
List<InternalInstrumented<SocketStats>> getListenSocketStatsList();
72+
@Nullable List<InternalInstrumented<SocketStats>> getListenSocketStatsList();
7573

7674
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ public final class ServerImpl extends io.grpc.Server implements InternalInstrume
143143
InternalServer transportServer,
144144
Context rootContext) {
145145
this.executorPool = Preconditions.checkNotNull(builder.executorPool, "executorPool");
146-
147146
this.registry = Preconditions.checkNotNull(builder.registryBuilder.build(), "registryBuilder");
148147
this.fallbackRegistry =
149148
Preconditions.checkNotNull(builder.fallbackRegistry, "fallbackRegistry");

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

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -151,14 +151,12 @@ static final class Tracker {
151151
private ScheduledFuture<?> reportTimer;
152152

153153
void channelActive(Channel channel) {
154-
if (metricRecorder != null) {
155-
List<String> labelValues = getLabelValues(channel);
156-
metricRecorder.addLongCounter(metrics.connectionsCreated, 1,
157-
Collections.emptyList(), labelValues);
158-
metricRecorder.addLongUpDownCounter(metrics.connectionCount, 1,
159-
Collections.emptyList(), labelValues);
160-
scheduleNextReport(channel, true);
161-
}
154+
List<String> labelValues = getLabelValues(channel);
155+
metricRecorder.addLongCounter(metrics.connectionsCreated, 1,
156+
Collections.emptyList(), labelValues);
157+
metricRecorder.addLongUpDownCounter(metrics.connectionCount, 1,
158+
Collections.emptyList(), labelValues);
159+
scheduleNextReport(channel, true);
162160
}
163161

164162
private void scheduleNextReport(final Channel channel, boolean isInitial) {
@@ -188,21 +186,19 @@ void channelInactive(Channel channel) {
188186
if (reportTimer != null) {
189187
reportTimer.cancel(false);
190188
}
191-
if (metricRecorder != null) {
192-
List<String> labelValues = getLabelValues(channel);
193-
metricRecorder.addLongUpDownCounter(metrics.connectionCount, -1,
194-
Collections.emptyList(), labelValues);
195-
// Final collection on close
196-
recordTcpInfo(channel, true);
197-
}
189+
List<String> labelValues = getLabelValues(channel);
190+
metricRecorder.addLongUpDownCounter(metrics.connectionCount, -1,
191+
Collections.emptyList(), labelValues);
192+
// Final collection on close
193+
recordTcpInfo(channel, true);
198194
}
199195

200196
void recordTcpInfo(Channel channel) {
201197
recordTcpInfo(channel, false);
202198
}
203199

204200
private void recordTcpInfo(Channel channel, boolean isClose) {
205-
if (metricRecorder == null || epollSocketChannelClass == null
201+
if (epollSocketChannelClass == null
206202
|| !epollSocketChannelClass.isInstance(channel)) {
207203
return;
208204
}

0 commit comments

Comments
 (0)