• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

grpc / grpc-java / #18811

25 Aug 2023 11:55PM UTC coverage: 88.293% (-0.02%) from 88.31%
#18811

push

github-actions

ejona86
interop-testing: Modernize stress test channel creation

OverrideAuthority() is the modern alternative to rewriting the
InetAddress, and can also work if we change the channel creation to use
target strings instead. We can use test CAs now without resorting to the
Netty-specific APIs. After this change, only 4 classes in
interop-testing depend on Netty.

30333 of 34355 relevant lines covered (88.29%)

0.88 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

90.63
/../netty/src/main/java/io/grpc/netty/ClientTransportLifecycleManager.java
1
/*
2
 * Copyright 2016 The gRPC 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.grpc.netty;
18

19
import com.google.errorprone.annotations.CanIgnoreReturnValue;
20
import io.grpc.Status;
21
import io.grpc.internal.ManagedClientTransport;
22

23
/** Maintainer of transport lifecycle status. */
24
final class ClientTransportLifecycleManager {
25
  private final ManagedClientTransport.Listener listener;
26
  private boolean transportReady;
27
  private boolean transportShutdown;
28
  private boolean transportInUse;
29
  /** null iff !transportShutdown. */
30
  private Status shutdownStatus;
31
  /** null iff !transportShutdown. */
32
  private Throwable shutdownThrowable;
33
  private boolean transportTerminated;
34

35
  public ClientTransportLifecycleManager(ManagedClientTransport.Listener listener) {
1✔
36
    this.listener = listener;
1✔
37
  }
1✔
38

39
  public void notifyReady() {
40
    if (transportReady || transportShutdown) {
1✔
41
      return;
×
42
    }
43
    transportReady = true;
1✔
44
    listener.transportReady();
1✔
45
  }
1✔
46

47
  /**
48
   * Marks transport as shutdown, but does not set the error status. This must eventually be
49
   * followed by a call to notifyShutdown.
50
   */
51
  public void notifyGracefulShutdown(Status s) {
52
    if (transportShutdown) {
1✔
53
      return;
1✔
54
    }
55
    transportShutdown = true;
1✔
56
    listener.transportShutdown(s);
1✔
57
  }
1✔
58

59
  /** Returns {@code true} if was the first shutdown. */
60
  @CanIgnoreReturnValue
61
  public boolean notifyShutdown(Status s) {
62
    notifyGracefulShutdown(s);
1✔
63
    if (shutdownStatus != null) {
1✔
64
      return false;
1✔
65
    }
66
    shutdownStatus = s;
1✔
67
    shutdownThrowable = s.asException();
1✔
68
    return true;
1✔
69
  }
70

71
  public void notifyInUse(boolean inUse) {
72
    if (inUse == transportInUse) {
1✔
73
      return;
×
74
    }
75
    transportInUse = inUse;
1✔
76
    listener.transportInUse(inUse);
1✔
77
  }
1✔
78

79
  public void notifyTerminated(Status s) {
80
    if (transportTerminated) {
1✔
81
      return;
×
82
    }
83
    transportTerminated = true;
1✔
84
    notifyShutdown(s);
1✔
85
    listener.transportTerminated();
1✔
86
  }
1✔
87

88
  public Status getShutdownStatus() {
89
    return shutdownStatus;
1✔
90
  }
91

92
  public Throwable getShutdownThrowable() {
93
    return shutdownThrowable;
1✔
94
  }
95
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc