freemarker-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ddek...@apache.org
Subject [freemarker] 04/04: To investigate odd cinit NPE occurring on Travis
Date Thu, 17 Jan 2019 10:00:48 GMT
This is an automated email from the ASF dual-hosted git repository.

ddekany pushed a commit to branch 3
in repository https://gitbox.apache.org/repos/asf/freemarker.git

commit 86ca4d31eeb5d8f9c210d1d4c9b0377e37d0e87b
Author: ddekany <ddekany@apache.org>
AuthorDate: Thu Jan 17 10:58:45 2019 +0100

    To investigate odd cinit NPE occurring on Travis
---
 .../src/main/java/org/apache/freemarker/core/Configuration.java   | 8 +++++++-
 .../apache/freemarker/core/UnsupportedFM2TemplateLanguage.java    | 8 +++++++-
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/Configuration.java b/freemarker-core/src/main/java/org/apache/freemarker/core/Configuration.java
index 03a8a55..5f57c26 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/Configuration.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/Configuration.java
@@ -792,9 +792,15 @@ public final class Configuration implements TopLevelConfiguration, CustomStateSc
         PREDEFINED_TEMPLATE_LANGUAGES_BY_EXTENSION = new HashMap<String, TemplateLanguage>(32);
         
         for (TemplateLanguage tl : DefaultTemplateLanguage.STANDARD_INSTANCES) {
-            PREDEFINED_TEMPLATE_LANGUAGES_BY_EXTENSION.put(tl.getFileExtension(), tl);  
         
+            if (tl == null) {
+                throw new AssertionError("tl was null");
+            }
+            PREDEFINED_TEMPLATE_LANGUAGES_BY_EXTENSION.put(tl.getFileExtension(), tl);
         }
         for (TemplateLanguage tl : UnsupportedFM2TemplateLanguage.INSTANCES) {
+            if (tl == null) {
+                throw new AssertionError("tl was null");
+            }
             PREDEFINED_TEMPLATE_LANGUAGES_BY_EXTENSION.put(tl.getFileExtension(), tl);  
         
         }
         PREDEFINED_TEMPLATE_LANGUAGES_BY_EXTENSION.put(
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/UnsupportedFM2TemplateLanguage.java
b/freemarker-core/src/main/java/org/apache/freemarker/core/UnsupportedFM2TemplateLanguage.java
index e67091d..073d4e6 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/UnsupportedFM2TemplateLanguage.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/UnsupportedFM2TemplateLanguage.java
@@ -24,6 +24,7 @@ import java.io.InputStream;
 import java.io.Reader;
 
 import org.apache.freemarker.core.outputformat.OutputFormat;
+import org.apache.freemarker.core.util._NullArgumentException;
 
 /**
  * FreeMarker 2 template language, which we don't support. To avoid confusion we ban loading
such templates. 
@@ -37,7 +38,12 @@ class UnsupportedFM2TemplateLanguage extends TemplateLanguage {
     private static final UnsupportedFM2TemplateLanguage FTLX = new UnsupportedFM2TemplateLanguage(
             "ftlx", null, AutoEscapingPolicy.ENABLE_IF_DEFAULT);
     
-    static final UnsupportedFM2TemplateLanguage[] INSTANCES = new UnsupportedFM2TemplateLanguage[]
{ FTL, FTLH, FTLX };
+    static final UnsupportedFM2TemplateLanguage[] INSTANCES =
+            new UnsupportedFM2TemplateLanguage[] {
+                    _NullArgumentException.check(FTL),
+                    _NullArgumentException.check(FTLH),
+                    _NullArgumentException.check(FTLX)
+    };
     
     private UnsupportedFM2TemplateLanguage(String fileExtension, OutputFormat outputFormat,
             AutoEscapingPolicy autoEscapingPolicy) {


Mime
View raw message