incubator-esme-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vassil Dichev <vdic...@apache.org>
Subject Re: Actions with Lift 2.2 (was: Move to latest Lift release for 1.2)
Date Sun, 19 Dec 2010 15:58:40 GMT
Scala's Map implementation probably suppresses these warnings.


On Sun, Dec 19, 2010 at 5:30 PM, Richard Hirsch <hirsch.dick@gmail.com> wrote:
> Should we turn on warnings / deprecated code messages for the compiler
> - I think both are currently suppressed.
>
> D
>
> On Sun, Dec 19, 2010 at 4:22 PM, Vassil Dichev <vdichev@apache.org> wrote:
>> Now that you've mentioned it, I was curious why it worked. It doesn't
>> have anything to do with Lift, but with Scala. Here's the reason:
>>
>> Let's define a simple object, which delegates equals to its member
>> field (don't try this at home).
>>
>> --------------------------------------------------------------------------------
>> class Obj(i: Int) { override def equals(o: Any) = o == i }
>> --------------------------------------------------------------------------------
>>
>> Now let's see what happens if you create an object and compare it with
>> the same value its member field has.
>>
>> This is what happens in Scala 2.7.7:
>> --------------------------------------------------------------------------------
>> 2 == new Obj(2)
>>
>> warning: comparing values of types Int and Obj using `==' will always
>> yield false
>>       2 == new Obj(2)
>>         ^
>> res5: Boolean = true
>> --------------------------------------------------------------------------------
>>
>> Curiously, the compiler warns you that this will yield false, but
>> still returns true :-) Scala 2.8 keeps its promise though, so the
>> result is actually false.
>>
>> This would also mean that the "contains" method in a map will always
>> return false now, and "get" will always return None.
>>
>> Vassil
>>
>>
>> On Sun, Dec 19, 2010 at 3:55 PM, Vladimir Ivanov <lester.mail@gmail.com> wrote:
>>> Ethan, Vassil
>>>
>>> Yes, I've got it now. Thanks for the explanation!
>>>
>>> 2010/12/19 Vassil Dichev <vdichev@apache.org>
>>>
>>>> Yes, I'm sure that there wasn't an implicit conversion before, just as
>>>> there isn't one now. Probably the definition of hashCode and/or equals
>>>> has changed (let's remember that both need to work in order to get
>>>> something out of a map). I don't see where exactly, but this must be
>>>> it.
>>>>
>>>> Vassil
>>>>
>>>>
>>>> On Sun, Dec 19, 2010 at 10:57 AM, Ethan Jewett <esjewett@gmail.com>
wrote:
>>>> > Hi Vladimir,
>>>> >
>>>> > You've got the first half of the problem: The MessagePullActor is sent
>>>> > the MessagePullActor.StartPullActor(id, lastMsg, feed) message in line
>>>> > 214 of Action.scala. The "id" here is a MappedLongIndex. I've changed
>>>> > it to "id.is", which just returns a Long, I believe.
>>>> >
>>>> > The problem occurs because the MessagePullActor is sent the message
>>>> > MessagePullActor.Fetch(td.performId) in line 277 of UserActor.scala.
>>>> > Here the td.performId is a Long.
>>>> >
>>>> > Within MessagePullActor, a map is populated with "id" as the key in
>>>> > the first call. In the second call the same map has get(td.performId)
>>>> > called on it, with the intent of retrieving the map relationship
>>>> > stored in the first call. But since (I guess) a Long is no longer
>>>> > equal to a MappedLongIndex in Scala 2.8 (???) this doesn't work any
>>>> > more. get(td.performId) just returns a None() instead of the
>>>> > Some(MessagePullActor(...)) that it used to return.
>>>> >
>>>> > Does that seem like the right explanation to you? I'm not sure if
>>>> > that's really the reason, but I assume something like that is going
>>>> > on.
>>>> >
>>>> > Ethan
>>>> >
>>>> > On Sun, Dec 19, 2010 at 1:56 AM, Vladimir Ivanov <lester.mail@gmail.com>
>>>> wrote:
>>>> >> Ethan,
>>>> >>
>>>> >> I have a little misunderstanding - you wrote that MappedLong had
been
>>>> used
>>>> >> to search in a Map(Any, LiftActor) in MessagePullActor and Long
had been
>>>> as
>>>> >> a key to store value. But where had this conversion happend? I neither
>>>> see
>>>> >> it in PF below nor I can figure out what implicit conversion had
been
>>>> >> applied. It seems to me like the same obj (MappedLong) was used
to store
>>>> >> value.
>>>> >>
>>>> >> case StartPullActor(obj, lastMessage, messageSource) =>
>>>> >>      if (!messagePullActors.contains(obj)) {
>>>> >>        val pullActor = new MessagePullActor(Distributor, lastMessage,
>>>> >> messageSource)
>>>> >>        messagePullActors += (obj -> pullActor)
>>>> >>        pullActor ! StartUp
>>>> >>      }
>>>> >>
>>>> >> 2010/12/19 Ethan Jewett <esjewett@gmail.com>
>>>> >>
>>>> >>> Ahhh, so is it accurate to say that the problem is that when
the
>>>> >>> parameter is Any the compiler is not doing an implicit conversion
from
>>>> >>> MappedLongKey to Long, but when the parameter is Long it tips
off the
>>>> >>> compiler that the implicit conversion is necessary? Of course,
in that
>>>> >>> case I don't understand why this ever worked :-)
>>>> >>>
>>>> >>> Ethan
>>>> >>>
>>>> >>> On Sat, Dec 18, 2010 at 10:42 PM, Vassil Dichev <vdichev@apache.org>
>>>> >>> wrote:
>>>> >>> > Thanks Ethan! I noticed now that I have tried to create
a very
>>>> generic
>>>> >>> > Map, but now restricted the key type from Any to Long in
order to
>>>> >>> > avoid this type of error in the future.
>>>> >>> >
>>>> >>> > I've also just fixed a bug caused by different treatment
of XML node
>>>> >>> > equality in Scala 2.7 and 2.8. If I remember correctly,
many Lift
>>>> >>> > tests failed because of this when they tried to migrate
to Scala 2.8.
>>>> >>> >
>>>> >>> > Vassil
>>>> >>> >
>>>> >>> >
>>>> >>> > On Sat, Dec 18, 2010 at 10:03 PM, Ethan Jewett <esjewett@gmail.com>
>>>> >>> wrote:
>>>> >>> >> This is (I believe) fixed. We were using a MappedLongKey
to do a
>>>> >>> >> lookup in a map but we were storing the value being
looked up with a
>>>> >>> >> key that was just a Long. I guess this doesn't work
any more? :-)
>>>> >>> >>
>>>> >>> >> Ethan
>>>> >>> >>
>>>> >>> >> On Sat, Dec 18, 2010 at 1:03 PM, Richard Hirsch <
>>>> hirsch.dick@gmail.com>
>>>> >>> wrote:
>>>> >>> >>> Strange - There is no exception in the log file
on stax. .....
>>>> >>> >>>
>>>> >>> >>> D.
>>>> >>> >>>
>>>> >>> >>> On Sat, Dec 18, 2010 at 1:00 PM, Richard Hirsch
<
>>>> hirsch.dick@gmail.com>
>>>> >>> wrote:
>>>> >>> >>>> Let me take a look on stax to see if I see
anything in the log
>>>> file.
>>>> >>> >>>>
>>>> >>> >>>> D.
>>>> >>> >>>>
>>>> >>> >>>> On Sat, Dec 18, 2010 at 12:38 PM, Vladimir
Ivanov <
>>>> >>> lester.mail@gmail.com> wrote:
>>>> >>> >>>>> Hello Ethan,
>>>> >>> >>>>>
>>>> >>> >>>>> I just want to say that this action also
works locally in trunk
>>>> for
>>>> >>> me.
>>>> >>> >>>>>
>>>> >>> >>>>> Thank you!
>>>> >>> >>>>>
>>>> >>> >>>>> 2010/12/18 Ethan Jewett <esjewett@gmail.com>
>>>> >>> >>>>>
>>>> >>> >>>>>> Hi Vassil,
>>>> >>> >>>>>>
>>>> >>> >>>>>> Cool, thanks for checking. In case
it wasn't clear, Stax is
>>>> >>> currently
>>>> >>> >>>>>> on the Lift 2.2 build. It is where
I first noticed this problem.
>>>> If
>>>> >>> >>>>>> you build trunk locally, I think the
action will work (it did
>>>> for
>>>> >>> me).
>>>> >>> >>>>>>
>>>> >>> >>>>>> Vladimir, no problem with the questions.
Ask all you want. We
>>>> really
>>>> >>> >>>>>> appreciate it :-)
>>>> >>> >>>>>>
>>>> >>> >>>>>> Cheers,
>>>> >>> >>>>>> Ethan
>>>> >>> >>>>>>
>>>> >>> >>>>>> On Fri, Dec 17, 2010 at 11:19 PM, Vassil
Dichev <
>>>> vdichev@apache.org
>>>> >>> >
>>>> >>> >>>>>> wrote:
>>>> >>> >>>>>> > Ethan, I tested both the test
and the action, and none seems
>>>> to
>>>> >>> work
>>>> >>> >>>>>> > on the stax instance. Will check
locally.
>>>> >>> >>>>>> >
>>>> >>> >>>>>> >
>>>> >>> >>>>>> > On Fri, Dec 17, 2010 at 6:53 PM,
Ethan Jewett <
>>>> esjewett@gmail.com
>>>> >>> >
>>>> >>> >>>>>> wrote:
>>>> >>> >>>>>> >> I have been able to recreate
this problem locally. "every X
>>>> min"
>>>> >>> >>>>>> >> actions simply do not fire
on the Lift 2.2 branch. It looks
>>>> like
>>>> >>> the
>>>> >>> >>>>>> >> scheduler never gets started
but there are no error messages.
>>>> On
>>>> >>> the
>>>> >>> >>>>>> >> trunk, these types of actions
still work fine.
>>>> >>> >>>>>> >>
>>>> >>> >>>>>> >> I am going to be pretty busy
this weekend and next week, but
>>>> I'll
>>>> >>> try
>>>> >>> >>>>>> >> to look into it. If anyone
else has any ideas or wants to try
>>>> to
>>>> >>> >>>>>> >> diagnose the problem, go for
it!
>>>> >>> >>>>>> >>
>>>> >>> >>>>>> >> Example action that grabs
my Jira items and makes them into
>>>> >>> messages:
>>>> >>> >>>>>> >>
>>>> >>> >>>>>> >> Test: every 1 mins
>>>> >>> >>>>>> >> Action: rss:
>>>> >>> >>>>>>
>>>> >>>
>>>> http://issues.apache.org/jira/sr/jira.issueviews:searchrequest-xml/temp/SearchRequest.xml?pid=12310850&reporterSelect=specificuser&reporter=esjewett&sorter/field=issuekey&sorter/order=DESC&tempMax=1000
>>>> >>> >>>>>> >>
>>>> >>> >>>>>> >> Ethan
>>>> >>> >>>>>> >>
>>>> >>> >>>>>> >> On Wed, Dec 15, 2010 at 6:52
PM, Ethan Jewett <
>>>> >>> esjewett@gmail.com>
>>>> >>> >>>>>> wrote:
>>>> >>> >>>>>> >>> There is a potential problem
with actions. I created some
>>>> new
>>>> >>> Jira
>>>> >>> >>>>>> >>> items that should be pulled
in by my RSS pull action that
>>>> runs
>>>> >>> every 5
>>>> >>> >>>>>> >>> minutes. It's been about
10 minutes and so far I see
>>>> nothing.
>>>> >>> >>>>>> >>>
>>>> >>> >>>>>> >>> Dick, I wonder if you
have a chance, can take a look at the
>>>> Stax
>>>> >>> logs
>>>> >>> >>>>>> >>> and see if there is anything
within the last 15 minutes or
>>>> so?
>>>> >>> It is
>>>> >>> >>>>>> >>> about 18:45 ECT (17:45
GMT) now, I think. I'm really bad at
>>>> >>> timezones
>>>> >>> >>>>>> >>> though, so I might be
confused :-)
>>>> >>> >>>>>> >>>
>>>> >>> >>>>>> >>> Thanks,
>>>> >>> >>>>>> >>> Ethan
>>>> >>> >>>>>> >>>
>>>> >>> >>>>>> >>
>>>> >>> >>>>>> >
>>>> >>> >>>>>> >
>>>> >>> >>>>>> >
>>>> >>> >>>>>> > --
>>>> >>> >>>>>> > Twitter: http://twitter.com/vdichev
>>>> >>> >>>>>> > Blog: http://speaking-my-language.blogspot.com
>>>> >>> >>>>>> >
>>>> >>> >>>>>>
>>>> >>> >>>>>
>>>> >>> >>>>>
>>>> >>> >>>>>
>>>> >>> >>>>> --
>>>> >>> >>>>> Best Regards,
>>>> >>> >>>>> Vladimir Ivanov
>>>> >>> >>>>>
>>>> >>> >>>>
>>>> >>> >>>
>>>> >>> >>
>>>> >>> >
>>>> >>> >
>>>> >>> >
>>>> >>> > --
>>>> >>> > Twitter: http://twitter.com/vdichev
>>>> >>> > Blog: http://speaking-my-language.blogspot.com
>>>> >>> >
>>>> >>>
>>>> >>
>>>> >>
>>>> >>
>>>> >> --
>>>> >> Best Regards,
>>>> >> Vladimir Ivanov
>>>> >>
>>>> >
>>>>
>>>>
>>>>
>>>> --
>>>> Twitter: http://twitter.com/vdichev
>>>> Blog: http://speaking-my-language.blogspot.com
>>>>
>>>
>>>
>>>
>>> --
>>> Best Regards,
>>> Vladimir Ivanov
>>>
>>
>>
>>
>> --
>> Twitter: http://twitter.com/vdichev
>> Blog: http://speaking-my-language.blogspot.com
>>
>



-- 
Twitter: http://twitter.com/vdichev
Blog: http://speaking-my-language.blogspot.com

Mime
View raw message