Skip to content

Commit

Permalink
finagle-mux: Preserve RetryableNackFailure log level when reusing fla…
Browse files Browse the repository at this point in the history
…gs from context

Problem

If RdispatchNack propagates flags, it should still have similar behavior to if flags aren't propagated.

Solution

Copy the RetryableNackFailure instead of constructing a wholly new Failure.

Result

Instead of using the default log level, we reuse the RetryableNackFailure log level.  Nothing else is changed.

Differential Revision: https://phabricator.twitter.biz/D214841
  • Loading branch information
mosesn authored and jenkins committed Sep 25, 2018
1 parent 3c3fedc commit 8737db3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ private[finagle] object ReqRepFilter {

case Message.RdispatchNack(_, contexts) =>
val exn = MuxFailure.fromContexts(contexts) match {
case Some(f) => Failure(Failure.RetryableNackFailure.why, f.finagleFlags)
case Some(f) => Failure.RetryableNackFailure.withFlags(f.finagleFlags)
case None => Failure.RetryableNackFailure
}
Throw(exn)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.twitter.finagle.mux

import com.twitter.finagle.Failure
import com.twitter.finagle.mux.transport.{Message, MuxFailure}
import com.twitter.logging.Level
import org.scalatest.FunSuite

class ReqRepFilterTest extends FunSuite {
test("Hydrate a mux failure from a message with encoded error codes, so that it preserves the" +
" flags and uses the right log level") {
val muxFailure = new MuxFailure(MuxFailure.NonRetryable | MuxFailure.Rejected)
val contexts = muxFailure.contexts
val msg = Message.RdispatchNack(1 /* tag */, contexts)
val actual = intercept[Failure] {
ReqRepFilter.reply(msg).get
}
assert(actual == Failure.RetryableNackFailure.withFlags(muxFailure.finagleFlags))
assert(actual.flags == muxFailure.finagleFlags)
assert(actual.logLevel == Level.DEBUG)
}
}

0 comments on commit 8737db3

Please sign in to comment.