diff --git a/src/main/java/sirius/pasta/tagliatelle/Tagliatelle.java b/src/main/java/sirius/pasta/tagliatelle/Tagliatelle.java index f94328353..a410f6646 100644 --- a/src/main/java/sirius/pasta/tagliatelle/Tagliatelle.java +++ b/src/main/java/sirius/pasta/tagliatelle/Tagliatelle.java @@ -94,20 +94,32 @@ public MultiMap getTagLibTags() { */ public List getExtensions(String target) { synchronized (extensions) { - List result = extensions.get(target); - if (result == null) { - // As we might re-enter this method while compiling templates in "loadExtensions" we provide a - // placeholder value here to avoid infinite recursions. (Under normal circumstances, this shouldn't - // happen anyway, as cyclic extensions make no sense at all). - extensions.put(target, new ArrayList<>()); - - // Load and fill the result list. Note that we cannot use HashMap.computeIfAbsent here, as - // loadExtensions itself compiles templates which might end up calling this method leading - // to a ConcurrentModificationException... - result = loadExtensions(target); - extensions.put(target, result); + try { + List result = extensions.get(target); + if (result == null) { + // As we might re-enter this method while compiling templates in "loadExtensions" we provide a + // placeholder value here to avoid infinite recursions. (Under normal circumstances, this shouldn't + // happen anyway, as cyclic extensions make no sense at all). + extensions.put(target, new ArrayList<>()); + + // Load and fill the result list. Note that we cannot use HashMap.computeIfAbsent here, as + // loadExtensions itself compiles templates which might end up calling this method leading + // to a ConcurrentModificationException... + result = loadExtensions(target); + extensions.put(target, result); + } + return Collections.unmodifiableList(result); + } catch (Exception exception) { + // If an error occurs while compiling the extensions, we remove our empty placeholder in debug + // environments, as it is very likely that the developer will fix the template and attempt to + // reload the page. If we didn't clear the extension, the page will simply show up empty. + // Note that if this happens in prod environments, we keep the empty list so that the same error + // only get reported once... + if (Sirius.isDev()) { + extensions.remove(target); + } + throw exception; } - return Collections.unmodifiableList(result); } } @@ -126,7 +138,7 @@ private List loadExtensions(String target) { private TemplateExtension resolveToTemplateExtension(String path) { try { Optional