Skip to content

Commit 34af8f9

Browse files
committed
early returns to avoid deep nesting
1 parent d3c7ebb commit 34af8f9

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

  • dd-java-agent/instrumentation/spark/spark-common/src/main/java/datadog/trace/instrumentation/spark

dd-java-agent/instrumentation/spark/spark-common/src/main/java/datadog/trace/instrumentation/spark/EmrUtils.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,17 @@ class EmrUtils {
2020
static String getEmrStepId() {
2121
try {
2222
String userDir = System.getProperty("user.dir");
23-
if (userDir != null) {
24-
Path workDir = Paths.get(userDir).getFileName();
25-
if (workDir != null) {
26-
Matcher matcher = EMR_STEP_ID_PATTERN.matcher(workDir.toString());
27-
if (matcher.matches()) {
28-
log.debug("EMR step ID extracted: {}", matcher.group(1));
29-
return matcher.group(1);
30-
}
31-
}
23+
if (userDir == null) {
24+
return null;
25+
}
26+
Path workDir = Paths.get(userDir).getFileName();
27+
if (workDir == null) {
28+
return null;
29+
}
30+
Matcher matcher = EMR_STEP_ID_PATTERN.matcher(workDir.toString());
31+
if (matcher.matches()) {
32+
log.debug("EMR step ID extracted: {}", matcher.group(1));
33+
return matcher.group(1);
3234
}
3335
} catch (Throwable t) {
3436
log.debug("Unable to extract EMR step ID from working directory", t);

0 commit comments

Comments
 (0)