akka/akka-http

Wrong Marshalling when Entity is `Optional`

Open

#559 opened on Nov 20, 2016

View on GitHub
 (11 comments) (0 reactions) (0 assignees)Scala (598 forks)batch import
1 - triagedhelp wantedt:routing

Repository metrics

Stars
 (1,311 stars)
PR merge metrics
 (Avg merge 1d 10h) (2 merged PRs in 30d)

Description

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

Contributor guide