Skip to content
This repository has been archived by the owner on Jun 16, 2024. It is now read-only.

Commit

Permalink
fix: make sure we could apply the getParent() method on confPath whil…
Browse files Browse the repository at this point in the history
…e it is a file name only.

❯ java -jar build/libs/solconfig.jar create default.json
java.lang.NullPointerException: Cannot invoke "java.nio.file.Path.toFile()" because the return value of "java.nio.file.Path.getParent()" is null
	at com.solace.tools.solconfig.SempClient.freeMakerToString(SempClient.java:223)
	at com.solace.tools.solconfig.SempClient.readMapFromJsonFile(SempClient.java:211)
	at com.solace.tools.solconfig.Commander.getConfigBrokerFromFile(Commander.java:112)
	at com.solace.tools.solconfig.Commander.create(Commander.java:98)
	at com.solace.tools.solconfig.cli.CreateCommand.execute(CreateCommand.java:24)
	at com.solace.tools.solconfig.cli.SubCommand.call(SubCommand.java:15)
	at com.solace.tools.solconfig.cli.SubCommand.call(SubCommand.java:7)
	at picocli.CommandLine.executeUserObject(CommandLine.java:1953)
	at picocli.CommandLine.access$1300(CommandLine.java:145)
	at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2352)
	at picocli.CommandLine$RunLast.handle(CommandLine.java:2346)
	at picocli.CommandLine$RunLast.handle(CommandLine.java:2311)
	at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2179)
	at picocli.CommandLine.execute(CommandLine.java:2078)
	at com.solace.tools.solconfig.App.main(App.java:11)
  • Loading branch information
flyisland committed Jan 25, 2022
1 parent 252f330 commit 37129cf
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/java/com/solace/tools/solconfig/SempClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ public static Map<String, Object> readMapFromJsonFile(Path confPath) {
private static String freeMakerToString(Path confPath) {
try {
Configuration cfg = new Configuration(Configuration.VERSION_2_3_31);
cfg.setDirectoryForTemplateLoading(confPath.getParent().toFile());
cfg.setDirectoryForTemplateLoading(confPath.toAbsolutePath().getParent().toFile());
cfg.setDefaultEncoding("UTF-8");
cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
cfg.setLogTemplateExceptions(false);
Expand Down

0 comments on commit 37129cf

Please sign in to comment.