Skip to content

Commit

Permalink
removed redundant null checks
Browse files Browse the repository at this point in the history
  • Loading branch information
littleaj committed Jun 12, 2019
1 parent aad0506 commit 2451bb6
Showing 1 changed file with 4 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public AgentConfiguration parseConfigurationFile(String baseFolder) {
setBuiltInInstrumentation(agentConfiguration, instrumentationTag);

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

Expand Down Expand Up @@ -181,11 +181,7 @@ private void getForbiddenPaths(Element parent, AgentConfigurationDefaultImpl age

HashSet<String> excludedPrefixes = new HashSet<String>();

NodeList addClasses = forbiddenElement.getElementsByTagName(FORBIDDEN_PREFIX_TAG);
if (addClasses == null) {
return;
}

NodeList addClasses = forbiddenElement.getElementsByTagName(FORBIDDEN_PREFIX_TAG); // can't be null
for (int index = 0; index < addClasses.getLength(); ++index) {
Element classElement = getClassDataElement(addClasses.item(index));
if (classElement == null) {
Expand Down Expand Up @@ -372,16 +368,12 @@ private synchronized void initializeAgentLogger(Element topElementTag, AgentConf
}

private NodeList getAllClassesToInstrument(Element tag) {
NodeList addClasses = tag.getElementsByTagName(CLASS_TAG);
if (addClasses == null) {
return null;
}
return addClasses;
return tag.getElementsByTagName(CLASS_TAG); // can't be null
}

private void addMethods(ClassInstrumentationData classData, Element eClassNode) {
NodeList methodNodes = eClassNode.getElementsByTagName(METHOD_TAG);
if (methodNodes == null || methodNodes.getLength() == 0) {
if (methodNodes.getLength() == 0) {
if (classData.isReportCaughtExceptions() || classData.isReportExecutionTime()) {
classData.addAllMethods(classData.isReportCaughtExceptions(), classData.isReportExecutionTime());
}
Expand Down

0 comments on commit 2451bb6

Please sign in to comment.