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

grpc / grpc-java / #20035
89%

Build:
DEFAULT BRANCH: master
Ran 29 Oct 2025 05:37PM UTC
Jobs 1
Files 621
Run time 2min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

29 Oct 2025 05:26PM UTC coverage: 88.537% (+0.02%) from 88.514%
#20035

push

github

web-flow
Flatten the BinderTransports using the "guard clause" pattern (#12449)

`Binder[Client/Server]Transport` uses the following "single exit point"
style/pattern of control flow all over the place:
```
if (inState(ExpectedState)) {
  if (!doStep1ThatCanFail()) {
    // error handling
  } else if (!doStep2ThatCanFail()) {
    // error handling
  } else if (...) {
    ...
  } else {
    // Happy case.
  }
}
```

This has the advantage of a single exit point which, in C-like languages
has historically been useful for unconditional cleanup like releasing
locks and closing resources. However, in Java with exceptions,
unconditional cleanup has to happen in a finally block and so we don't
really benefit. On the other hand the single exit point pattern creates
a lot of nesting:
- The happy case is always nested at least two levels deep in an `else`.
- Inserting a new no-fail step in the sequence (say between 1 and 2) is
awkward. You have to either create an empty error handling block or
create a new "else" clause, increasing the indent/nesting level by one.

In this PR, I reduce nesting and make life easier for future PRs by
converting all BinderTransport methods to use the guard clause pattern
instead:

https://refactoring.com/catalog/replaceNestedConditionalWithGuardClauses.html

https://testing.googleblog.com/2017/06/code-health-reduce-nesting-reduce.html

34966 of 39493 relevant lines covered (88.54%)

0.89 hits per line

Uncovered Existing Lines

Lines Coverage ∆ File
1
94.12
-1.18% ../netty/src/main/java/io/grpc/netty/WriteBufferingAndExceptionHandler.java
1
74.23
-1.03% ../servlet/src/main/java/io/grpc/servlet/AsyncServletOutputStreamWriter.java
1
91.9
-0.48% ../xds/src/main/java/io/grpc/xds/client/ControlPlaneClient.java
Jobs
ID Job ID Ran Files Coverage
1 #20035.1 29 Oct 2025 05:37PM UTC 621
88.54
Source Files on build #20035
  • Tree
  • List 621
  • Changed 7
  • Source Changed 0
  • Coverage Changed 7
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • Github Actions Build #20035
  • 82755807 on github
  • Prev Build on master
  • Next Build on master
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