grpc / grpc/grpc-java

StatusException and StatusRuntimeException not serializable

Aperta
#1,913 20 commenti 7 reazioni 0 assegnatari Vedi su GitHub
enhancement
Lingua principale
Java
Stelle
12.1k
Fork
4k
Merge medio
2g 17h
PR unite (30g)
37

Descrizione

StatusException and StatusRuntimeException are not serializable due to containing a Status object (which makes no attempt to be serializable) with no special handling.

Here's a snippet from the exception that arises:

```
... snip ...
Caused by: java.io.NotSerializableException: io.grpc.Status
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1184)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1548)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1509)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1548)
at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:441)
at java.lang.Throwable.writeObject(Throwable.java:985)
at sun.reflect.GeneratedMethodAccessor129.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
... snip ...
```

Our use case is an RMI-like API to make calls to a server process which is then making gRPC calls. In this case an operation failed and then things go really wrong because we can't see the root problem since the real exception can't be serialized.

I think to be a "good citizen" the Status*Exceptions should be serializable so it would seem that either:
- Status should also be
- The status should be pulled apart and the pieces stored in the exception classes
- Special serialization routines should be put in place to pull the Status apart on write and put them back together on read

If you know which approach you'd like to take, I'd be happy to implement it.

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Start with the StatusException and StatusRuntimeException classes and reproduce serialization using the failure shown in the issue. Compare the possible handling for the contained Status and decide how serialized exceptions should preserve their status information; done means both exception types serialize and deserialize without NotSerializableException.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
java
Ambito
backend-api-design
Tipo di issue
Bug
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.