[akka-user] akka-remote: If the configuration file contains an invalid settings, log message is null.

2015-07-02 Thread okyongsu


environment:

   - jdk 1.8.0_40-b26
   - scala 2.11.7
   - akka-remote 2.3.11

If *akka-remote* configuration contains an *invalid *settings,

# setting
log-frame-size-exceeding = off# valid
log-frame-size-exceeding = 1000b  # valid
log-frame-size-exceeding = on # invalid (error prone)

the following log message occurs.

address is now gated for [5000] ms. Reason: [exception during creation] Caused 
by: [*null*]

detail log message: 

[WARN] [07/02/2015 11:32:24.896] 
[pulse-service-web-akka.remote.default-remote-dispatcher-5] 
[akka.tcp:///system/endpointManager/reliableEndpointWriter-akka.tcp]
 Association with remote system [akka.tcp://] has failed, address is 
now gated for [5000] ms. Reason: [exception during creation] Caused by: [null]
[ERROR] [07/02/2015 11:32:54.908] 
[pulse-service-web-akka.actor.default-dispatcher-22] 
[ActorSystem(pulse-service-web)] Error during processing of request 
HttpRequest(..)
akka.pattern.AskTimeoutException: Ask timed out on 
[ActorSelection[Anchor(akka.tcp:///), Path(/user/report)]] after [3 
ms]
at 
akka.pattern.PromiseActorRef$$anonfun$1.apply$mcV$sp(AskSupport.scala:334)
at akka.actor.Scheduler$$anon$7.run(Scheduler.scala:117)
at 
scala.concurrent.Future$InternalCallbackExecutor$.unbatchedExecute(Future.scala:599)
at 
scala.concurrent.BatchingExecutor$class.execute(BatchingExecutor.scala:109)
at 
scala.concurrent.Future$InternalCallbackExecutor$.execute(Future.scala:597)
at 
akka.actor.LightArrayRevolverScheduler$TaskHolder.executeTask(Scheduler.scala:467)
at 
akka.actor.LightArrayRevolverScheduler$$anon$8.executeBucket$1(Scheduler.scala:419)
at 
akka.actor.LightArrayRevolverScheduler$$anon$8.nextTick(Scheduler.scala:423)
at 
akka.actor.LightArrayRevolverScheduler$$anon$8.run(Scheduler.scala:375)
at java.lang.Thread.run(Thread.java:745)


and debug result.


https://lh3.googleusercontent.com/-c9_Svwc4D5M/VZTUWzyd_LI/ELc/83o02GvrNDw/s1600/intellij-debugging.png


How to solve it like this?

diff --git a/akka-remote/src/main/scala/akka/remote/Endpoint.scala 
b/akka-remote/src/main/scala/akka/remote/Endpoint.scala
index af3ec82..3c747b4 100644
--- a/akka-remote/src/main/scala/akka/remote/Endpoint.scala
+++ b/akka-remote/src/main/scala/akka/remote/Endpoint.scala
@@ -28,6 +28,7 @@ import scala.util.control.NonFatal
 import java.util.concurrent.locks.LockSupport
 import scala.concurrent.Future
 import scala.concurrent.blocking
+import java.lang.reflect.InvocationTargetException
  /**
  * INTERNAL API
@@ -210,7 +211,12 @@ private[remote] class ReliableDeliverySupervisor(
   override val supervisorStrategy = OneForOneStrategy(loggingEnabled = false) {
 case e @ (_: AssociationProblem) ⇒ Escalate
 case NonFatal(e) ⇒
-  val causedBy = if (e.getCause == null)  else sCaused by: 
[${e.getCause.getMessage}]
+
+  val causedBy = Option(e.getCause).withFilter(_ != null).flatMap {
+case ec: InvocationTargetException ⇒ Option(ec.getCause).withFilter(_ 
!= null).map(_.getMessage)
+case ec⇒ Some(ec.getMessage)
+  }.fold()(message ⇒ sCaused by: [$message])
+
   log.warning(Association with remote system [{}] has failed, address is 
now gated for [{}] ms. Reason: [{}] {},
 remoteAddress, settings.RetryGateClosedFor.toMillis, e.getMessage, 
causedBy)
   uidConfirmed = false // Need confirmation of UID again

-- 
  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+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


Re: [akka-user] akka-remote: If the configuration file contains an invalid settings, log message is null.

2015-07-02 Thread Viktor Klang
Hi okyongsu,

thanks for the report!

It does seem, at a glance, like the proposed fix merely treats the symptom
rather than the problem.
I wonder if there is a cleaner way to deal with this.

On Thu, Jul 2, 2015 at 8:26 AM, okyongsu okyon...@gmail.com wrote:

 environment:

- jdk 1.8.0_40-b26
- scala 2.11.7
- akka-remote 2.3.11

 If *akka-remote* configuration contains an *invalid *settings,

 # setting
 log-frame-size-exceeding = off# valid
 log-frame-size-exceeding = 1000b  # valid
 log-frame-size-exceeding = on # invalid (error prone)

 the following log message occurs.

 address is now gated for [5000] ms. Reason: [exception during creation] 
 Caused by: [*null*]

 detail log message:

 [WARN] [07/02/2015 11:32:24.896] 
 [pulse-service-web-akka.remote.default-remote-dispatcher-5] 
 [akka.tcp:///system/endpointManager/reliableEndpointWriter-akka.tcp]
  Association with remote system [akka.tcp://] has failed, address is 
 now gated for [5000] ms. Reason: [exception during creation] Caused by: [null]
 [ERROR] [07/02/2015 11:32:54.908] 
 [pulse-service-web-akka.actor.default-dispatcher-22] 
 [ActorSystem(pulse-service-web)] Error during processing of request 
 HttpRequest(..)
 akka.pattern.AskTimeoutException: Ask timed out on 
 [ActorSelection[Anchor(akka.tcp:///), Path(/user/report)]] after 
 [3 ms]
 at 
 akka.pattern.PromiseActorRef$$anonfun$1.apply$mcV$sp(AskSupport.scala:334)
 at akka.actor.Scheduler$$anon$7.run(Scheduler.scala:117)
 at 
 scala.concurrent.Future$InternalCallbackExecutor$.unbatchedExecute(Future.scala:599)
 at 
 scala.concurrent.BatchingExecutor$class.execute(BatchingExecutor.scala:109)
 at 
 scala.concurrent.Future$InternalCallbackExecutor$.execute(Future.scala:597)
 at 
 akka.actor.LightArrayRevolverScheduler$TaskHolder.executeTask(Scheduler.scala:467)
 at 
 akka.actor.LightArrayRevolverScheduler$$anon$8.executeBucket$1(Scheduler.scala:419)
 at 
 akka.actor.LightArrayRevolverScheduler$$anon$8.nextTick(Scheduler.scala:423)
 at 
 akka.actor.LightArrayRevolverScheduler$$anon$8.run(Scheduler.scala:375)
 at java.lang.Thread.run(Thread.java:745)


 and debug result.



 https://lh3.googleusercontent.com/-c9_Svwc4D5M/VZTUWzyd_LI/ELc/83o02GvrNDw/s1600/intellij-debugging.png


 How to solve it like this?

 diff --git a/akka-remote/src/main/scala/akka/remote/Endpoint.scala 
 b/akka-remote/src/main/scala/akka/remote/Endpoint.scala
 index af3ec82..3c747b4 100644
 --- a/akka-remote/src/main/scala/akka/remote/Endpoint.scala
 +++ b/akka-remote/src/main/scala/akka/remote/Endpoint.scala
 @@ -28,6 +28,7 @@ import scala.util.control.NonFatal
  import java.util.concurrent.locks.LockSupport
  import scala.concurrent.Future
  import scala.concurrent.blocking
 +import java.lang.reflect.InvocationTargetException
   /**
   * INTERNAL API
 @@ -210,7 +211,12 @@ private[remote] class ReliableDeliverySupervisor(
override val supervisorStrategy = OneForOneStrategy(loggingEnabled = 
 false) {
  case e @ (_: AssociationProblem) ⇒ Escalate
  case NonFatal(e) ⇒
 -  val causedBy = if (e.getCause == null)  else sCaused by: 
 [${e.getCause.getMessage}]
 +
 +  val causedBy = Option(e.getCause).withFilter(_ != null).flatMap {
 +case ec: InvocationTargetException ⇒ 
 Option(ec.getCause).withFilter(_ != null).map(_.getMessage)
 +case ec⇒ Some(ec.getMessage)
 +  }.fold()(message ⇒ sCaused by: [$message])
 +
log.warning(Association with remote system [{}] has failed, address 
 is now gated for [{}] ms. Reason: [{}] {},
  remoteAddress, settings.RetryGateClosedFor.toMillis, e.getMessage, 
 causedBy)
uidConfirmed = false // Need confirmation of UID again

  --
  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+unsubscr...@googlegroups.com.
 To post to this group, send email to akka-user@googlegroups.com.
 Visit this group at http://groups.google.com/group/akka-user.
 For more options, visit https://groups.google.com/d/optout.




-- 
Cheers,
√

-- 
  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+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at