From 4231c20fde3e5fff89f5c46443e00a7eedb42535 Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Sat, 27 Jul 2013 18:30:48 +0200 Subject: [PATCH] update mustache to version 0.8.13 --- scm-webapp/pom.xml | 2 +- .../scm/template/MustacheTemplateEngine.java | 59 ++++++++++++------- 2 files changed, 38 insertions(+), 23 deletions(-) diff --git a/scm-webapp/pom.xml b/scm-webapp/pom.xml index 3b14bbf1f4..3e34106640 100644 --- a/scm-webapp/pom.xml +++ b/scm-webapp/pom.xml @@ -456,7 +456,7 @@ 1.13.1 1.0 3.0.5 - 0.8.12 + 0.8.13 Tomcat diff --git a/scm-webapp/src/main/java/sonia/scm/template/MustacheTemplateEngine.java b/scm-webapp/src/main/java/sonia/scm/template/MustacheTemplateEngine.java index 2aab1a86b3..318b3222a6 100644 --- a/scm-webapp/src/main/java/sonia/scm/template/MustacheTemplateEngine.java +++ b/scm-webapp/src/main/java/sonia/scm/template/MustacheTemplateEngine.java @@ -36,6 +36,7 @@ package sonia.scm.template; //~--- non-JDK imports -------------------------------------------------------- import com.github.mustachejava.Mustache; +import com.github.mustachejava.MustacheException; import com.google.common.base.Throwables; import com.google.common.util.concurrent.ThreadFactoryBuilder; @@ -92,8 +93,7 @@ public class MustacheTemplateEngine implements TemplateEngine ThreadFactory threadFactory = new ThreadFactoryBuilder().setNameFormat(THREAD_NAME).build(); - factory.setExecutorService(Executors. - newCachedThreadPool(threadFactory)); + factory.setExecutorService(Executors.newCachedThreadPool(threadFactory)); } //~--- get methods ---------------------------------------------------------- @@ -166,29 +166,15 @@ public class MustacheTemplateEngine implements TemplateEngine } catch (MustacheTemplateNotFoundException ex) { - if (logger.isWarnEnabled()) - { - logger.warn("could not find mustache template at {}", templatePath); - } + logger.warn("could not find mustache template at {}", templatePath); } catch (UncheckedExecutionException ex) { - Throwable cause = ex.getCause(); - - if (cause instanceof MustacheTemplateNotFoundException) - { - if (logger.isWarnEnabled()) - { - logger.warn("could not find mustache template at {}", templatePath); - } - } - else - { - Throwables.propagateIfInstanceOf(cause, IOException.class); - - throw new TemplateParseException( - "could not parse template for resource ".concat(templatePath), cause); - } + handleWrappedException(ex, templatePath); + } + catch (MustacheException ex) + { + handleWrappedException(ex, templatePath); } catch (Exception ex) { @@ -213,6 +199,35 @@ public class MustacheTemplateEngine implements TemplateEngine return TYPE; } + //~--- methods -------------------------------------------------------------- + + /** + * Method description + * + * + * @param ex + * @param templatePath + * + * @throws IOException + */ + private void handleWrappedException(Exception ex, String templatePath) + throws IOException + { + Throwable cause = ex.getCause(); + + if (cause instanceof MustacheTemplateNotFoundException) + { + logger.warn("could not find mustache template at {}", templatePath); + } + else + { + Throwables.propagateIfInstanceOf(cause, IOException.class); + + throw new TemplateParseException( + "could not parse template for resource ".concat(templatePath), cause); + } + } + //~--- fields --------------------------------------------------------------- /** Field description */