From 272711e6f7eed94d933380599cb434a5cfe38f00 Mon Sep 17 00:00:00 2001 From: Jonatan Kronqvist Date: Mon, 15 Dec 2014 15:07:15 +0200 Subject: Fix the license checker after elemental.json #15383 The elemental.json update changed how null values and string representations of numbers were parsed, which caused a lot of tests for CvalChecker to fail. Unfortunately the tests were never run in an automated fashion, which means that they were never discovered until we stumbled upon it due to the issue reported in #15383 Change-Id: If2cb9fa96effea7ce55a4ffe6d1666ca7521e1fb --- client-compiler/src/com/vaadin/tools/CvalChecker.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'client-compiler/src') diff --git a/client-compiler/src/com/vaadin/tools/CvalChecker.java b/client-compiler/src/com/vaadin/tools/CvalChecker.java index b3345c7658..645667be94 100644 --- a/client-compiler/src/com/vaadin/tools/CvalChecker.java +++ b/client-compiler/src/com/vaadin/tools/CvalChecker.java @@ -35,16 +35,17 @@ import java.util.prefs.Preferences; import org.apache.commons.io.IOUtils; import elemental.json.JsonException; +import elemental.json.JsonNull; import elemental.json.JsonObject; import elemental.json.impl.JsonUtil; /** * This class is able to validate the vaadin CVAL license. - * + * * It reads the developer license file and asks the server to validate the * licenseKey. If the license is invalid it throws an exception with the * information about the problem and the server response. - * + * * @since 7.3 */ public final class CvalChecker { @@ -80,6 +81,10 @@ public final class CvalChecker { private static T get(JsonObject o, String k, Class clz) { Object ret = null; try { + if (o == null || o.get(k) == null + || o.get(k) instanceof JsonNull) { + return null; + } if (clz == String.class) { ret = o.getString(k); } else if (clz == JsonObject.class) { @@ -299,7 +304,7 @@ public final class CvalChecker { /** * Given a product name returns the name of the file with the license key. - * + * * Traditionally we have delivered license keys with a name like * 'vaadin.touchkit.developer.license' but our database product name is * 'vaadin-touchkit' so we have to replace '-' by '.' to maintain @@ -340,7 +345,7 @@ public final class CvalChecker { /** * Validate whether there is a valid license key for a product. - * + * * @param productName * for example vaadin-touchkit * @param productVersion -- cgit v1.2.3