-
Notifications
You must be signed in to change notification settings - Fork 12
Handling exceptions from user-supplied lambdas in GraphRequestAction #18
base: master
Are you sure you want to change the base?
Changes from 2 commits
d7ddb07
1f7a9c9
d8871c8
3929115
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,12 +12,14 @@ import java.util.concurrent.ExecutorService | |
| import java.util.concurrent.TimeUnit.MICROSECONDS | ||
|
|
||
| import akka.actor.ActorSystem | ||
| import com.datastax.driver.dse.graph.GraphStatement | ||
| import com.datastax.gatling.plugin.DseProtocol | ||
| import com.datastax.gatling.plugin.metrics.MetricsLogger | ||
| import com.datastax.gatling.plugin.model.DseGraphAttributes | ||
| import com.datastax.gatling.plugin.response.GraphResponseHandler | ||
| import com.datastax.gatling.plugin.utils._ | ||
| import io.gatling.commons.stats.KO | ||
| import io.gatling.commons.validation.Validation | ||
| import io.gatling.core.action.{Action, ExitableAction} | ||
| import io.gatling.core.session.Session | ||
| import io.gatling.core.stats.StatsEngine | ||
|
|
@@ -69,7 +71,18 @@ class GraphRequestAction(val name: String, | |
| ThroughputVerifier.checkForGatlingOverloading(session, gatlingTimingSource) | ||
| GatlingResponseTime.startedByGatling(session, gatlingTimingSource) | ||
| } | ||
| val stmt = dseAttributes.statement.buildFromSession(session) | ||
|
|
||
| // Attempt to generate a graph statement from our parameters, propagating any uncaught exceptions after | ||
| // continuing the chain with a failed session | ||
| val stmt: Validation[GraphStatement] = try { | ||
| dseAttributes.statement.buildFromSession(session) | ||
| } catch { | ||
| case e: Throwable => { | ||
| logger.error("Failed to generate GraphStatement", e) | ||
| next ! session.markAsFailed | ||
| throw e | ||
| } | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You wrapped the call I think that the fix should be located in
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the insight. Gatling's I just pushed a new commit that moves exception handling down to DseGraphStatements.scala:54 as directed, but uses What do you think? Theoretically, pushing down exception handling like this could allow some other implementation of
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
That's a good reason to use a try/catch block, indeed. +1 for that approach
I agree with you. I also wondered whether to keep the extra try/catch in GraphRequestAction, just to be 100% future proof. But I think the way to go is to honor the type system and make it clear that errors are prevented.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Sounds good, I'll stick to the pushdown approach and update the tests to match. Thank you for addressing this. |
||
|
|
||
| stmt.onFailure(err => { | ||
| val responseTime = responseTimeBuilder.build() | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the comment lines are not accurate anymore here, could you restore the original line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, I'll delete that comment