From d891da7136542d04003c799fac6812fe4e288101 Mon Sep 17 00:00:00 2001 From: David Estes Date: Tue, 25 Apr 2023 12:51:20 -0400 Subject: [PATCH] null safety --- README.md | 3 ++- build.gradle | 2 +- .../bertramlabs/plugins/hcl4j/HCLBaseFunctions.java | 12 ++++++------ 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index c99d6c8..b9a1788 100644 --- a/README.md +++ b/README.md @@ -16,12 +16,13 @@ Using gradle one can include the hcl4j dependency like so: ```groovy dependencies { - compile "com.bertramlabs.plugins:hcl4j:0.6.8" + compile "com.bertramlabs.plugins:hcl4j:0.7.0" } ``` ## What's New +* **0.7.0** Adding some null safety on some of the base functions * **0.6.9** Fixed some null pointer issues if content on base64encode was null and some exceptions on array traversal * **0.6.8** Fixed ! (not) operator and added base64encode, base64decode, textdecodebase64, textencodebase64 * **0.6.7** Fixed operators called on variables without spaces diff --git a/build.gradle b/build.gradle index 3eab30f..6006925 100644 --- a/build.gradle +++ b/build.gradle @@ -30,7 +30,7 @@ ext { group = 'com.bertramlabs.plugins' -version = '0.6.9' +version = '0.7.0' ext.isReleaseVersion = !version.endsWith("SNAPSHOT") sourceCompatibility = "1.8" diff --git a/src/main/java/com/bertramlabs/plugins/hcl4j/HCLBaseFunctions.java b/src/main/java/com/bertramlabs/plugins/hcl4j/HCLBaseFunctions.java index 2554242..c083b3a 100644 --- a/src/main/java/com/bertramlabs/plugins/hcl4j/HCLBaseFunctions.java +++ b/src/main/java/com/bertramlabs/plugins/hcl4j/HCLBaseFunctions.java @@ -24,21 +24,21 @@ public class HCLBaseFunctions { static void registerBaseFunctions(HCLParser parser) { parser.registerFunction("upper", (arguments) -> { - if(arguments.size() > 0) { + if(arguments.size() > 0 && arguments.get(0) != null) { return arguments.get(0).toString().toUpperCase(Locale.ROOT); } return null; }); parser.registerFunction("lower", (arguments) -> { - if(arguments.size() > 0) { + if(arguments.size() > 0 && arguments.get(0) != null) { return arguments.get(0).toString().toLowerCase(Locale.ROOT); } return null; }); parser.registerFunction("format", (arguments) -> { - if(arguments.size() > 0) { + if(arguments.size() > 0 && arguments.get(0) != null) { String val = arguments.get(0).toString(); ArrayList args = new ArrayList<>(); for(int x=1;x { - if(arguments.size() > 0) { + if(arguments.size() > 0 && arguments.get(0) != null) { return arguments.get(0).toString(); } return null; @@ -59,7 +59,7 @@ static void registerBaseFunctions(HCLParser parser) { parser.registerFunction("trim", (arguments) -> { - if(arguments.size() > 0) { + if(arguments.size() > 0 && arguments.get(0) != null) { return arguments.get(0).toString(); } return null; @@ -67,7 +67,7 @@ static void registerBaseFunctions(HCLParser parser) { parser.registerFunction("strrev", (arguments) -> { - if(arguments.size() > 0) { + if(arguments.size() > 0 && arguments.get(0) != null) { String str = arguments.get(0).toString(); String reversed = ""; char ch;