Make ServerImpl's internalClose thread-safe
- Vorherrschende Sprache
- Java
- Sterne
- 12.1k
- Forks
- 4k
- Ø Merge
- 2 T. 17 Std.
- Gemergte PRs (30 T.)
- 37
Beschreibung
So we have this in `ServerImpl.JumpToApplicationThreadServerStreamListener`:
```java
/**
* Like {@link ServerCall#close(Status, Metadata)}, but thread-safe for internal use.
*/
private void internalClose() {
// TODO(ejona86): this is not thread-safe :)
stream.close(Status.UNKNOWN, new Metadata());
}
```
We should fix that. There's two ways to fix this:
1. Allow truncated messages in our stream and deliver trailers. This would be nicest and would be helpful in other cases (like if too many requests are sent in a server call), as we can deliver a message to the client
2. Treat this as a cancel and send RST_STREAM. This would be similar to client-side cancellation, but we'd still need to verify it'd be safe on server-side.
In either case it'd probably be good if we made this trigger onCancel instead of onCompleted. That'd probably happen naturally for (2), but (1) would need special plumbing, but it's probably not too onerous.
Beitragsleitfaden
Rechercherichtung
Start at ServerImpl.JumpToApplicationThreadServerStreamListener and trace internalClose through stream.close. Compare the truncated-message/trailers and cancellation alternatives, including their onCancel versus onCompleted behavior; done means internalClose is thread-safe and the resulting callback semantics are verified.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- java
- Bereich
- api, backend
- Issue-Typ
- Bug
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100