Issue with default query parameters and custom unmarshalling

31 views
Skip to first unread message

andrew...@bottlerocketstudios.com

unread,
Aug 22, 2016, 12:26:02 PM8/22/16
to Akka User List

I recently came across an issue when I had used `parameters(…)` with custom unmarshalling and a default value. I found that `parameters(“foo”.as[MyType] ?)` compiles, but the following did not: `parameters(“foo”.as[MyType] ? MyType.default)`. The compiler says that there are "too many parameters for method 'parameters(...' The only thing that seemed to compile was placing a string on the right side of the `?` instead of a concrete type. This took me about two hours to figure out because it was not apparent in the documentation: http://doc.akka.io/docs/akka/2.4/scala/http/routing-dsl/directives/parameter-directives/parameters.html

 

Note, knowing that `parameters(“foo” ? 0)` works for an Int, I tried the following to no avail, thinking that the type could be inferred correctly and unmarshalled: `parameters(“foo” ? MyType.default)`.

 

I would suggest an update to the referenced documentation to give an example for using a default value while using a custom unmarshaller. Any enlightenment on the reason for this, or if I am missing something, would be super helpful! Thanks!

andrew...@bottlerocketstudios.com

unread,
Aug 22, 2016, 2:15:37 PM8/22/16
to Akka User List
Update, the following also compiles: `parameters("foo" ?[MyType] MyType.default)`. Could the original problem simply be a compiler bug?

andrew...@bottlerocketstudios.com

unread,
Aug 22, 2016, 2:15:49 PM8/22/16
to Akka User List
Also, I am using Scala 2.11.7 and Akka 2.4.8 (so it's not an issue with Scala 2.10).


On Monday, August 22, 2016 at 11:26:02 AM UTC-5, andrew...@bottlerocketstudios.com wrote:

Konrad Malawski

unread,
Aug 22, 2016, 3:04:26 PM8/22/16
to akka...@googlegroups.com, andrew...@bottlerocketstudios.com
Hmm... it could be.
Quick question – do you perhaps have the ask pattern imported in this file?

It could cause ambiguity with the ? from ask I just thought.

-- 
Konrad `ktoso` Malawski
Akka @ Lightbend
--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ: http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+...@googlegroups.com.
To post to this group, send email to akka...@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

andrew...@bottlerocketstudios.com

unread,
Aug 22, 2016, 3:37:07 PM8/22/16
to Akka User List
Good thought, though I checked and do not. Are you able to reproduce this behavior?


On Monday, August 22, 2016 at 11:26:02 AM UTC-5, andrew...@bottlerocketstudios.com wrote:

Konrad Malawski

unread,
Aug 28, 2016, 7:14:01 PM8/28/16
to Akka User List
I'm not able to reproduce, if you could post a reproducer as akka/akka issue then we'd be able to look at it.
Thanks in advance

--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ: http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+unsubscribe@googlegroups.com.

To post to this group, send email to akka...@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.



--
Cheers,

andrew...@bottlerocketstudios.com

unread,
Aug 29, 2016, 1:42:00 PM8/29/16
to Akka User List
OK, I'll try to get a minimal reproducing case when I have some time.


On Monday, August 22, 2016 at 11:26:02 AM UTC-5, andrew...@bottlerocketstudios.com wrote:
Reply all
Reply to author
Forward
0 new messages