binder: Ownership story for Parcelables in Metadata is inconsistent and undocumented.
- Vorherrschende Sprache
- Java
- Sterne
- 12.1k
- Forks
- 4k
- Ø Merge
- 2 T. 17 Std.
- Gemergte PRs (30 T.)
- 37
Beschreibung
Parcelables can contain file descriptors or other resources that must be closed, for example `android.os.SharedMemory` and `ParcelFileDescriptor`. But `io.grpc.binder.ParcelableUtils` doesn't say anything about who takes ownership of such objects when stored in Metadata.
Metadata has no close() method so perhaps the application layer is in the best position to own the Parcelables it sends/receives ([g/client-services/c/jxtspAxVYFs](http://g/client-services/c/jxtspAxVYFs)). Senders should install an interceptor that calls close from either ClientCall.Listener#onClose or ServerCall.Listener#onComplete(). On the flip side, Parcelable receivers should install an interceptor that extracts Parcelables from headers/trailers and closes them upon onClose/onComplete. We should users about this duty and provide them with suitable interceptors.
We also need to reconcile this change with the current behavior, which does *sometimes* close these resources. In particular, the ParcelableInputStream path taken when using the binder transport always writes a Parcelable with flags=`PARCELABLE_WRITE_RETURN_VALUE`, which normally closes it. However:
- this only applies to the sender side
- this close seems wrong because transparent retries might necessitate writing the same Parcelable more than once
- the `marshalUnmarshall` path taken by the in-process transport does *not* call close, in contrast, yet the application layer shouldn't have to know what transport is in use.
Beitragsleitfaden
Rechercherichtung
Beginne mit io.grpc.binder.ParcelableUtils und verfolge die Pfade von ParcelableInputStream und marshalUnmarshall, einschließlich ihres Verhaltens beim Schließen von Ressourcen. Prüfe die vorgeschlagenen Interceptor-Punkte ClientCall.Listener#onClose und ServerCall.Listener#onComplete. Als abgeschlossen gilt die Arbeit, wenn die Ownership über die Transports hinweg konsistent ist, transparente Retries sicher sind und die Verantwortlichkeit sowie geeignete Interceptors dokumentiert sind.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- android, java
- Bereich
- api, backend-api-design
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 25/100