2121import static java .lang .Math .max ;
2222
2323import com .google .common .base .MoreObjects ;
24- import com .google .common .base .Optional ;
2524import com .google .common .io .ByteStreams ;
2625import com .google .common .util .concurrent .ListenableFuture ;
2726import com .google .common .util .concurrent .SettableFuture ;
5453import io .grpc .internal .ManagedClientTransport ;
5554import io .grpc .internal .NoopClientStream ;
5655import io .grpc .internal .ObjectPool ;
57- import io .grpc .internal .ServerListener ;
5856import io .grpc .internal .ServerStream ;
5957import io .grpc .internal .ServerStreamListener ;
6058import io .grpc .internal .ServerTransport ;
@@ -90,7 +88,6 @@ final class InProcessTransport implements ServerTransport, ConnectionClientTrans
9088 private final int clientMaxInboundMetadataSize ;
9189 private final String authority ;
9290 private final String userAgent ;
93- private final Optional <ServerListener > optionalServerListener ;
9491 private int serverMaxInboundMetadataSize ;
9592 private final boolean includeCauseWithStatus ;
9693 private ObjectPool <ScheduledExecutorService > serverSchedulerPool ;
@@ -139,8 +136,8 @@ protected void handleNotInUse() {
139136 }
140137 };
141138
142- private InProcessTransport (SocketAddress address , int maxInboundMetadataSize , String authority ,
143- String userAgent , Attributes eagAttrs , Optional < ServerListener > optionalServerListener ,
139+ public InProcessTransport (SocketAddress address , int maxInboundMetadataSize , String authority ,
140+ String userAgent , Attributes eagAttrs ,
144141 boolean includeCauseWithStatus , long assumedMessageSize ) {
145142 this .address = address ;
146143 this .clientMaxInboundMetadataSize = maxInboundMetadataSize ;
@@ -153,48 +150,23 @@ private InProcessTransport(SocketAddress address, int maxInboundMetadataSize, St
153150 .set (Grpc .TRANSPORT_ATTR_REMOTE_ADDR , address )
154151 .set (Grpc .TRANSPORT_ATTR_LOCAL_ADDR , address )
155152 .build ();
156- this .optionalServerListener = optionalServerListener ;
157153 logId = InternalLogId .allocate (getClass (), address .toString ());
158154 this .includeCauseWithStatus = includeCauseWithStatus ;
159155 this .assumedMessageSize = assumedMessageSize ;
160156 }
161157
162- public InProcessTransport (
163- SocketAddress address , int maxInboundMetadataSize , String authority , String userAgent ,
164- Attributes eagAttrs , boolean includeCauseWithStatus , long assumedMessageSize ) {
165- this (address , maxInboundMetadataSize , authority , userAgent , eagAttrs ,
166- Optional .<ServerListener >absent (), includeCauseWithStatus , assumedMessageSize );
167- }
168-
169- InProcessTransport (
170- String name , int maxInboundMetadataSize , String authority , String userAgent ,
171- Attributes eagAttrs , ObjectPool <ScheduledExecutorService > serverSchedulerPool ,
172- List <ServerStreamTracer .Factory > serverStreamTracerFactories ,
173- ServerListener serverListener , boolean includeCauseWithStatus , long assumedMessageSize ) {
174- this (new InProcessSocketAddress (name ), maxInboundMetadataSize , authority , userAgent , eagAttrs ,
175- Optional .of (serverListener ), includeCauseWithStatus , assumedMessageSize );
176- this .serverMaxInboundMetadataSize = maxInboundMetadataSize ;
177- this .serverSchedulerPool = serverSchedulerPool ;
178- this .serverStreamTracerFactories = serverStreamTracerFactories ;
179- }
180-
181158 @ CheckReturnValue
182159 @ Override
183160 public synchronized Runnable start (ManagedClientTransport .Listener listener ) {
184161 this .clientTransportListener = listener ;
185- if (optionalServerListener .isPresent ()) {
162+ InProcessServer server = InProcessServer .findServer (address );
163+ if (server != null ) {
164+ serverMaxInboundMetadataSize = server .getMaxInboundMetadataSize ();
165+ serverSchedulerPool = server .getScheduledExecutorServicePool ();
186166 serverScheduler = serverSchedulerPool .getObject ();
187- serverTransportListener = optionalServerListener .get ().transportCreated (this );
188- } else {
189- InProcessServer server = InProcessServer .findServer (address );
190- if (server != null ) {
191- serverMaxInboundMetadataSize = server .getMaxInboundMetadataSize ();
192- serverSchedulerPool = server .getScheduledExecutorServicePool ();
193- serverScheduler = serverSchedulerPool .getObject ();
194- serverStreamTracerFactories = server .getStreamTracerFactories ();
195- // Must be semi-initialized; past this point, can begin receiving requests
196- serverTransportListener = server .register (this );
197- }
167+ serverStreamTracerFactories = server .getStreamTracerFactories ();
168+ // Must be semi-initialized; past this point, can begin receiving requests
169+ serverTransportListener = server .register (this );
198170 }
199171 if (serverTransportListener == null ) {
200172 shutdownStatus = Status .UNAVAILABLE .withDescription ("Could not find server: " + address );
0 commit comments