akka/akka-http

Wrong Marshalling when Entity is `Optional`

Aperta

#559 aperta il 20 nov 2016

 (11 commenti) (0 reazioni) (0 assegnatari)Scala (598 fork)batch import
1 - triagedhelp wantedt:routing

Metriche repository

Star
 (1311 stelle)
Metriche merge PR
 (Merge medio 1g 10h) (2 PR mergiate in 30 g)

Descrizione

When completing a route with a Java Optional the output is not the one I would expect:

Expected Behavior

  • If Optional[T] is empty: completed with an empty Entity
  • If Optional[T] is not empty: completed with proper marshalling of T

Actual Behavior

  • If Optional[T] is empty: completed with {"present": false}
  • If Optional[T] is not empty: completed with {"present": true}

I have a gist where one can reproduce this: https://gist.github.com/jlprat/5e1c27ce4b912e0a3eb0ad56237246d7

Guida contributor