Skip to content

Agent findbugs fixes#945

Merged
littleaj merged 5 commits into
masterfrom
agent_findbugs_fixes
Jun 13, 2019
Merged

Agent findbugs fixes#945
littleaj merged 5 commits into
masterfrom
agent_findbugs_fixes

Conversation

@littleaj

Copy link
Copy Markdown
Contributor

No description provided.

@littleaj littleaj requested a review from trask June 12, 2019 20:57

String agentJarName = null;
File agentFolder = new File(agentJarLocation);
for (File file : agentFolder.listFiles()) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

listFiles() returns null if not a directory. The path should be a directory, but we don't verify so I'll let this fall through


NodeList addClasses = getAllClassesToInstrument(instrumentationTag);
if (addClasses == null) {
if (addClasses.getLength() == 0) { // can't be null; if empty, return

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Element.getElementsByTagName returns in empty NodeList in place of null

https://docs.oracle.com/javase/7/docs/api/org/w3c/dom/Element.html#getElementsByTagName(java.lang.String)

nodes = builtInElement.getElementsByTagName(MAX_STATEMENT_QUERY_LIMIT_TAG);
builtInConfigurationBuilder.setSqlMaxQueryLimitInMS(XmlParserUtils.getLong(XmlParserUtils.getFirst(nodes), MAX_STATEMENT_QUERY_LIMIT_TAG));

new BuiltInInstrumentedClassesBuilder().setSimpleBuiltInClasses(builtInConfigurationBuilder, builtInElement);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This method is static

valueStr = methodElement.getAttribute(THRESHOLD_ATTRIBUTE);
if (!StringUtils.isNullOrEmpty(valueStr)) {
try {
thresholdInMS = Long.valueOf(valueStr);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Unnecessary unbox rebox

return Long.parseLong(strValue);
} catch (NumberFormatException nfe) {
InternalLogger.INSTANCE.warn("Invalid attribute value. Expected number but was '%s'", strValue);
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

same here (unbox/rebox), but we need a try/catch

@littleaj littleaj force-pushed the agent_findbugs_fixes branch from 2451bb6 to 25a4484 Compare June 12, 2019 21:04
@littleaj littleaj merged commit ea25224 into master Jun 13, 2019
@littleaj littleaj deleted the agent_findbugs_fixes branch June 13, 2019 18:17
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

Successfully merging this pull request may close these issues.

2 participants