Skip to content

Commit 6dcd0d9

Browse files
committed
fix: NPE running init when no appmap.yml found
If there is no `appmap.yml` anywhere in the current directory tree, the `init` subcommand will fail with a NullPointerException. These changes make sure that doesn't happen.
1 parent a31bec3 commit 6dcd0d9

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

agent/src/main/java/com/appland/appmap/config/AppMapConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ private static Path findConfig(Path configFile, boolean mustExist) throws FileNo
9797
Files.createDirectories(projectDirectory);
9898
Files.write(configFile, getDefault(projectDirectory.toString()).getBytes());
9999

100-
return configFile;
100+
return configFile.toAbsolutePath();
101101
} catch (IOException e) {
102102
logger.error(e, "Failed to create default config");
103103
}

agent/test/agent_cli/agent_cli.bats

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,16 @@ load '../helper'
77
setup_file() {
88
export AGENT_JAR="$(find_agent_jar)"
99

10-
rm -rf test/agent_cli/spring-petclinic
11-
tar -C build/fixtures -c -f - ./spring-petclinic | tar -x -f - -C test/agent_cli
12-
cp -v test/petclinic/appmap.yml test/agent_cli/spring-petclinic/.
10+
TEST_DIR="$BATS_FILE_TMPDIR/agent_cli"
11+
mkdir -p "$TEST_DIR"
12+
rm -rf "$TEST_DIR"/spring-petclinic
1313

14-
cd test/agent_cli
14+
tar -C build/fixtures -c -f - ./spring-petclinic | tar -x -f - -C "$TEST_DIR"
15+
cp -v test/petclinic/appmap.yml "$TEST_DIR"/spring-petclinic/.
16+
17+
tar -c -f - -C test/agent_cli ./sampleproj | tar -x -f - -C "$TEST_DIR"
18+
19+
cd "$TEST_DIR"
1520
_configure_logging
1621

1722
}

0 commit comments

Comments
 (0)