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

Fixes for several string formats, they are based on static analysis. #6306

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ protected void computeFromPostBody(HTTPSamplerBase sampler,
HTTPFileArg [] files = {new HTTPFileArg(out.getPath(),"",contentType)};
sampler.setHTTPFiles(files);
} catch (IOException e) {
log.warn("Could not create binary file: {}", e);
log.warn("Could not create binary file", e);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want the complete stacktrace to be shown here?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The last "exception" parameter should not be present in the string format message, so ("Could not create binary file", e); is the right way to go to show the stacktrace

}
} else {
// Just put the whole postbody as the value of a parameter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ private void initClass() {
javaClass = Class.forName(name, false, Thread.currentThread().getContextClassLoader());
Method method = javaClass.getMethod("teardownTest", JavaSamplerContext.class);
isToBeRegistered = !method.getDeclaringClass().equals(AbstractJavaSamplerClient.class);
log.info("Created class: {}. Uses tearDownTest: ", name, isToBeRegistered);
log.info("Created class: {}. Uses tearDownTest: {}", name, isToBeRegistered);
} catch (Exception e) {
log.error("{}\tException initialising: ", whoAmI(), name, e);
log.error("{}\tException initialising: {} {}", whoAmI(), name, e.getMessage());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exception can be the last parameter without a placeholder, and it will render as a stacktrace, so .getMessage is not needed here.

Suggested change
log.error("{}\tException initialising: {} {}", whoAmI(), name, e.getMessage());
log.error("{}\tException initialising: {}", whoAmI(), name, e);

}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ private void closeSocket(String socketKey) {
try {
con.close();
} catch (IOException e) {
log.warn("Error closing socket {}", e); //$NON-NLS-1$
log.warn("Error closing socket", e); //$NON-NLS-1$
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, I think it is better to keep the short (string version) of the message here.

}
}
}
Expand Down
Loading