}
@Override
public void process(final Reader reader, final Writer writer)
throws IOException {
final StopWatch stopWatch = new StopWatch();
stopWatch.start("lessify");
Context context = Context.get();
HttpServletRequest request = context.getRequest();
String uri = request.getRequestURI();
try {
logger.debug("lessifying: {}", uri);
LessCompiler less = new LessCompiler();
String content = IOUtils.toString(reader);
writer.write(less.compile(content));
} catch (LessException ex) {
throw new LessRuntimeException(LessCssError.of(
uri, ex.getCause()), ex.getCause());
} finally {
// Rhino throws an exception when trying to exit twice. Make sure we don't
// get any exception
if (org.mozilla.javascript.Context.getCurrentContext() != null) {
org.mozilla.javascript.Context.exit();
}
IOUtils.closeQuietly(reader);
IOUtils.closeQuietly(writer);
stopWatch.stop();
logger.debug(stopWatch.prettyPrint());
}
}