NoSuchElementException when SQS receiver throws an Exception

APM Agent language and version:

Java - 1.35.0

Is there anything special in your setup? For example, are you using the Logstash or Kafka outputs? Are you using a load balancer in front of the APM Servers? Have you changed index pattern, generated custom templates, changed agent configuration etc.
NO

Description of the problem including expected versus actual behavior. Please include screenshots (if relevant):

Error happens when an Exception is thrown when method called from an AWS SQS receiver

Steps to reproduce:

  1. Receive a SQS message from AWS
  2. Throw an Exception

Errors in browser console (if relevant):

Provide logs and/or server output (if relevant):

java.util.NoSuchElementException
at java.base/java.util.ArrayDeque.removeFirst(Unknown Source)
at java.base/java.util.ArrayDeque.remove(Unknown Source)
at co.elastic.apm.agent.impl.ActiveStack.deactivate(ActiveStack.java:123)
at co.elastic.apm.agent.impl.ElasticApmTracer.deactivate(ElasticApmTracer.java:771)
at co.elastic.apm.agent.impl.transaction.AbstractSpan.deactivate(AbstractSpan.java:655)
at co.elastic.apm.agent.concurrent.RunnableCallableForkJoinTaskInstrumentation$AdviceClass.onExit(RunnableCallableForkJoinTaskInstrumentation.java:80)
at com.amazonaws.services.sqs.AmazonSQSAsyncClient$5.call(AmazonSQSAsyncClient.java:603)
at com.amazonaws.services.sqs.AmazonSQSAsyncClient$5.call(AmazonSQSAsyncClient.java:586)
at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)

Thanks, I'm looking into this

Please try with this snapshot (PR) - please try both with and without throwing the exception and check that you get the APM transaction displayed in the UI you expect in each situation (assuming there is a transaction here, if not please tell me that is not a relevant aspect). Thanks

How fast Jack!

Great, I'll update the agent and update the topic soon.

Thanks

Actually we have a higher level bug fix, so if you could try this snapshot from this PR, that would be better. Thanks