Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sr.getResponseDataAsString().length() throwing exception because getResponseDataAsString() is null #35

Open
dlebsock opened this issue Jan 3, 2024 · 0 comments

Comments

@dlebsock
Copy link

dlebsock commented Jan 3, 2024

HI!

This plugin has been very useful for propogating logs to my AI instance. There is one hiccup that I have run into, and that getResponseDataAsString() is returning null when there is no response returned. logResponseData is set to always but there are instances when a response is not returned..

if (logResponseData == DataLoggingOption.Always ||
(logResponseData == DataLoggingOption.OnFailure && !sr.isSuccessful())) {
String responseData;
if (sr.getResponseDataAsString().length() > MAX_DATA_LENGTH) {
log.warn("Response data is too long, truncating it to {} characters", MAX_DATA_LENGTH);
responseData = sr.getResponseDataAsString().substring(0, MAX_DATA_LENGTH) + "...[TRUNCATED]";
} else {
responseData = sr.getResponseDataAsString();

Here is a sample stack trace showcasing the issue:

2024-01-03 21:29:18,296 ERROR o.a.j.JMeter: Uncaught exception in thread Thread[Thread-4,5,main]
java.lang.NullPointerException: Cannot invoke "String.length()" because the return value of "org.apache.jmeter.samplers.SampleResult.getResponseDataAsString()" is null
at io.github.adrianmo.jmeter.backendlistener.azure.AzureBackendClient.trackRequest(AzureBackendClient.java:250) ~[jmeter.backendlistener.azure-0.2.9.jar:?]
at io.github.adrianmo.jmeter.backendlistener.azure.AzureBackendClient.handleSampleResults(AzureBackendClient.java:274) ~[jmeter.backendlistener.azure-0.2.9.jar:?]
at org.apache.jmeter.visualizers.backend.BackendListener.sendToListener(BackendListener.java:254) ~[ApacheJMeter_components.jar:5.5]
at org.apache.jmeter.visualizers.backend.BackendListener.access$600(BackendListener.java:50) ~[ApacheJMeter_components.jar:5.5]
at org.apache.jmeter.visualizers.backend.BackendListener$Worker.run(BackendListener.java:225) ~[ApacheJMeter_components.jar:5.5]

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant