apache / apache/jmeter

[BUG] Unhandled RuntimeException in PreProcessor or PostProcessor aborts remaining processors, assertions, and cleanup

Open
#6,734 1 comment 0 reactions 0 assignees View on GitHub
defect to-triage
Dominant language
Java
Stars
9.5k
Forks
2.3k
Avg merge
1d 22h
Merged PRs (30d)
5

Description

### Expected behavior

## Description
Currently in `JMeterThread.java`, execution loops for `PreProcessor`s (`runPreProcessors`) and `PostProcessor`s (`runPostProcessors`) do not wrap individual element processing in `try-catch` blocks.

If any `PreProcessor` or `PostProcessor` throws an unhandled `RuntimeException` (e.g. `NullPointerException`, `IndexOutOfBoundsException`, or malformed extraction error):
1. **Processor Execution Aborts**: The `for` loop in `runPreProcessors` / `runPostProcessors` immediately terminates, skipping all subsequent processors attached to the same sampler.
2. **Sampling Pipeline Bypass**: Uncaught exceptions in post-processors bypass downstream steps in `executeSamplePackage` including `checkAssertions()`, listener notifications (`notifyListeners`), and compiler resource cleanup (`compiler.done(pack)`).

By contrast, assertion processing in `JMeterThread.processAssertion()` explicitly wraps each assertion in `try-catch (Exception | JMeterError e)` to log errors and allow remaining pipeline elements to execute.

## Expected Behavior
When a `PreProcessor` or `PostProcessor` throws a runtime exception:
- The error should be logged with the element's name and stack trace.
- The thread should continue executing remaining `PreProcessor`s or `PostProcessor`s.
- Sample assertions, listener notifications, and compiler cleanup should execute normally.

### Actual behavior

An exception in a single processor breaks out of the loop, skipping all remaining processors, assertions, and test element cleanup.

### Steps to reproduce the problem

In `src/core/src/main/java/org/apache/jmeter/threads/JMeterThread.java`:
```java
private static void runPostProcessors(List extractors) {
for (PostProcessor ex : extractors) {
TestBeanHelper.prepare((TestElement) ex);
ex.process(); // Uncaught RuntimeException breaks loop and caller pipeline
}
}

### JMeter Version

6.0.0-SNAPSHOT

### Java Version

JDK 17 / JDK 21

### OS Version

_No response_

Contributor guide

Open the contributing guide

Research direction

Start in src/core/src/main/java/org/apache/jmeter/threads/JMeterThread.java by reading runPreProcessors, runPostProcessors, processAssertion, and executeSamplePackage to trace the processor and sampling pipeline. Done means processor failures are logged with their element names and stack traces, later processors continue, and assertions, listener notifications, and compiler cleanup still run.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.