update mustache to version 0.8.13

This commit is contained in:
Sebastian Sdorra
2013-07-27 18:30:48 +02:00
parent 204da78a05
commit 4231c20fde
2 changed files with 38 additions and 23 deletions

View File

@@ -456,7 +456,7 @@
<aether.version>1.13.1</aether.version> <aether.version>1.13.1</aether.version>
<wagon.version>1.0</wagon.version> <wagon.version>1.0</wagon.version>
<maven.version>3.0.5</maven.version> <maven.version>3.0.5</maven.version>
<mustache.version>0.8.12</mustache.version> <mustache.version>0.8.13</mustache.version>
<netbeans.hint.deploy.server>Tomcat</netbeans.hint.deploy.server> <netbeans.hint.deploy.server>Tomcat</netbeans.hint.deploy.server>
</properties> </properties>

View File

@@ -36,6 +36,7 @@ package sonia.scm.template;
//~--- non-JDK imports -------------------------------------------------------- //~--- non-JDK imports --------------------------------------------------------
import com.github.mustachejava.Mustache; import com.github.mustachejava.Mustache;
import com.github.mustachejava.MustacheException;
import com.google.common.base.Throwables; import com.google.common.base.Throwables;
import com.google.common.util.concurrent.ThreadFactoryBuilder; import com.google.common.util.concurrent.ThreadFactoryBuilder;
@@ -92,8 +93,7 @@ public class MustacheTemplateEngine implements TemplateEngine
ThreadFactory threadFactory = ThreadFactory threadFactory =
new ThreadFactoryBuilder().setNameFormat(THREAD_NAME).build(); new ThreadFactoryBuilder().setNameFormat(THREAD_NAME).build();
factory.setExecutorService(Executors. factory.setExecutorService(Executors.newCachedThreadPool(threadFactory));
newCachedThreadPool(threadFactory));
} }
//~--- get methods ---------------------------------------------------------- //~--- get methods ----------------------------------------------------------
@@ -166,29 +166,15 @@ public class MustacheTemplateEngine implements TemplateEngine
} }
catch (MustacheTemplateNotFoundException ex) 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) catch (UncheckedExecutionException ex)
{ {
Throwable cause = ex.getCause(); handleWrappedException(ex, templatePath);
}
if (cause instanceof MustacheTemplateNotFoundException) catch (MustacheException ex)
{ {
if (logger.isWarnEnabled()) handleWrappedException(ex, templatePath);
{
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);
}
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -213,6 +199,35 @@ public class MustacheTemplateEngine implements TemplateEngine
return TYPE; 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 --------------------------------------------------------------- //~--- fields ---------------------------------------------------------------
/** Field description */ /** Field description */