I am currently using freemarker v2.3.19 with camel and osgi. I am passing some optional osgi services into my template. I wrap any uses of these services inside an attempt/recover in case they are not available. Unfortunately, the attempt/recover fails to handle them when they are unavailable. The problem traces to the SimpleMethodModel class, inside the exec function. When the invocation fails, the catch block tries to build a TemplateModelException. However, line 130/131:
throw new TemplateModelException("Method " + getMember() +
" threw an exception when invoked on " + object, e);
results in a ServiceUnavailableException. This occurs because it tries to get a toString() on object to generate the error message, and that throws the exception. This results in a ServiceUnavailableException coming out of te function instead of a TeplateModelException, and it does not get handled by the attempt/recover, or anything else.
It seems the SimpleModelException should be handling everything and the intent would be only a TemplateModelException comes out, so that attempt/recover logic can handle that exception. However, in this particular case, where object.toString() generates an exception, this functionality breaks down.
Log in to post a comment.