/** {@inheritDoc} */
 @Override
 public void process(final Resource resource, final Reader reader, final Writer writer)
     throws IOException {
   final String content = IOUtils.toString(reader);
   final AbstractLinter linter = enginePool.getObject();
   try {
     // TODO investigate why linter fails when trying to reuse the same instance twice
     linter.setOptions(options).validate(content);
   } catch (final LinterException e) {
     onLinterException(e, resource);
   } catch (final WroRuntimeException e) {
     onException(e);
     final String resourceUri =
         resource == null ? StringUtils.EMPTY : "[" + resource.getUri() + "]";
     LOG.warn(
         "Exception while applying "
             + getClass().getSimpleName()
             + " processor on the "
             + resourceUri
             + " resource, no processing applied...",
         e);
   } finally {
     // don't change the processed content no matter what happens.
     writer.write(content);
     reader.close();
     writer.close();
     enginePool.returnObject(linter);
   }
 }
Beispiel #2
0
 private String doProcess(final String content) {
   CJson engine = enginePool.getObject();
   try {
     if (pack) {
       return engine.pack(content);
     }
     return engine.unpack(content);
   } finally {
     enginePool.returnObject(engine);
   }
 }