Actually, probally more like this (which actually compiles!):

  def defaultLocaleCalculator(request: Box[HttpServletRequest]):
Locale = request.flatMap(r => {
    tryo(r.getLocale()) match {
      case x @ Full(_) => x
      case _ => Empty
    }
  }).openOr(Locale.getDefault())

Cheers, Tim

On Mar 10, 4:16 pm, Tim Perrett <[email protected]> wrote:
> Guys,
>
> I think i might have just found a bug in the
> defaultLocaleCalculator... By simply adding S.?("mykey") to a comet
> actor, it bombs in spectacular style.
>
> I worked the bug back as it was originally getting an NPE from my
> code, so I shoved everything into boxes - that appears to have now
> moved the issue down into LiftRules...
>
> The default calculator looks like:
>
> request.flatMap(_.getLocale() match {case null => Empty case l: Locale
> => Full(l)}).openOr(Locale.getDefault())
>
> where request is Box[HttpServletRequest]. So then, flatMap is a method
> on Box, thats fine, but then:
>
> _.getLocale() match {...}
>
> The issue im seeing suggests that _ is actually null in this context
> and then throwing an NPE. This is easily solvable but involves shoving
> the placeholder into a box:
>
> request.flatMap(r => {
>   Box.!!(r.getLocale()) match {
>     case l: java.util.Locale => Full(loc)
>     case _ => Empty
>   }
>
> }).openOr(Locale.getDefault())
>
> Thoughts?
>
> Cheers, Tim
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to