binder: Ownership story for Parcelables in Metadata is inconsistent and undocumented.
- Lingua principale
- Java
- Stelle
- 12.1k
- Fork
- 4k
- Merge medio
- 2g 17h
- PR unite (30g)
- 37
Descrizione
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.
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia con io.grpc.binder.ParcelableUtils e segui i percorsi ParcelableInputStream e marshalUnmarshall, incluso il loro comportamento di chiusura delle risorse. Esamina i punti di intercettazione proposti ClientCall.Listener#onClose e ServerCall.Listener#onComplete. Il lavoro è completato quando la proprietà è coerente tra i transport, i retry trasparenti sono sicuri e la responsabilità e gli interceptor appropriati sono documentati.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- android, java
- Ambito
- api, backend-api-design
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 25/100