Re: [akka-user] DeadLetter and null senders

1,187 views
Skip to first unread message

Patrik Nordwall

unread,
Jan 9, 2013, 3:16:44 AM1/9/13
to akka...@googlegroups.com

On Wed, Jan 9, 2013 at 5:28 AM, Nicolas B. <nicolas...@gmail.com> wrote:
Hi,

since last Akka update (we're now using 2.1), I saw this exception popping in my logs from time to time :

java.lang.IllegalArgumentException: requirement failed: DeadLetter sender may not be null
        at scala.Predef$.require(Predef.scala:233) ~[scala-library-2.10.0.jar:na]
        at akka.actor.DeadLetter.<init>(ActorRef.scala:423) ~[akka-actor_2.10-2.1.0.jar:na]
        at akka.actor.DeadLetterActorRef.$bang(ActorRef.scala:481) ~[akka-actor_2.10-2.1.0.jar:na]
        at akka.actor.ActorRef.tell(ActorRef.scala:108) ~[akka-actor_2.10-2.1.0.jar:na]


This looks like a bug to me. I have created ticket https://www.assembla.com/spaces/akka/tickets/2882
Thanks for reporting.
 
Basically, when the single arg tell() has been deprecated I replace the few calls I had to the 2 args tell() using "null" as the sender. Is it wrong ? should I use a ref to some specific actor like deadletter ?

It is correct to use null when there is no sender. 

Until the bug is fixed you have to avoid sending to deadLetters without a real sender.

Regards,
Patrik


Thanks

N.


--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ: http://akka.io/faq/
>>>>>>>>>> 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 post to this group, send email to akka...@googlegroups.com.
To unsubscribe from this group, send email to akka-user+...@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user?hl=en.
 
 



--

Patrik Nordwall
Typesafe The software stack for applications that scale
Twitter: @patriknw

√iktor Ҡlang

unread,
Jan 9, 2013, 3:34:09 AM1/9/13
to Akka User List
It should automatically replace null with system.deadLetters in tell.

Cheers,
Viktor Klang
Director of Engineering

Typesafe - The software stack for applications that scale
Twitter: @viktorklang

Patrik Nordwall

unread,
Jan 9, 2013, 4:51:53 AM1/9/13
to akka...@googlegroups.com
Thanks, that was what I expected.

I guess you are interested in workaround until the issue is fixed.
Alt 1:
if (!getSender().isTerminated()) getSender().tell("pong", null);
Alt 2:
if (getSender() != getContext().system().deadLetters()) getSender().tell("pong", null);



On Wed, Jan 9, 2013 at 10:37 AM, Nicolas B. <nicolas...@gmail.com> wrote:
Hey,

here is a java test case that reproduce the issue.

It happens when replying to the DeadLetterActorRef with a null sender. One of my service is ack-ing all request, where some requester are doing fire-and-forget requests (null sender).

Wish I figured it out before the 2.1 release :)

N.


import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

import org.testng.Assert;
import org.testng.annotations.Test;

import akka.actor.*;


public class NullSenderTest {

    private volatile Throwable actorException;
   
    @Test
    public void canUseNullSender() throws Exception {
        final CountDownLatch latch = new CountDownLatch(1);
        class Ping extends UntypedActor {
            public void onReceive(Object msg) throws Exception {
                try {
                    // Sender is DeadLetter...
                    sender().tell("pong", null);
                } catch (Exception e) {
                    actorException = e;
                } finally {
                    latch.countDown();
                }
            }
        }
       
        ActorSystem system = ActorSystem.create();
        ActorRef ping = system.actorOf(new Props(new UntypedActorFactory() {
            public Actor create() throws Exception {
                return new Ping();
            }
        }));
        ping.tell("ping", null);
       
        latch.await(100, TimeUnit.MILLISECONDS);
       
        if (actorException != null) {
            Assert.fail(actorException.getMessage(), actorException);

        }
    }
}

--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ: http://akka.io/faq/
>>>>>>>>>> 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 post to this group, send email to akka...@googlegroups.com.
To unsubscribe from this group, send email to akka-user+...@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user?hl=en.
 
 

√iktor Ҡlang

unread,
Jan 9, 2013, 5:32:30 AM1/9/13
to Akka User List
Or:

sender().tell("pong", getContext().system().deadLetters())
Viktor Klang
Director of Engineering
Typesafe - The software stack for applications that scale
Twitter: @viktorklang
Reply all
Reply to author
Forward
0 new messages