docs: public ContentEncodedResource getResource(final Resource resource, final HttpServerExchange exchange) throws IOException {
          final String path = resource.getPath();
          Path file = resource.getFilePath();
          if (file == null) {
              return null;
          }
          if (minResourceSize > 0 && resource.getContentLength() < minResourceSize ||
                  maxResourceSize > 0 && resource.getContentLength() > maxResourceSize ||
                  !(encodingAllowed == null || encodingAllowed.resolve(exchange))) {
              return null;
          }
          AllowedContentEncodings encodings = contentEncodingRepository.getContentEncodings(exchange);
          if (encodings == null || encodings.isNoEncodingsAllowed()) {
              return null;
          }
          EncodingMapping encoding = encodings.getEncoding();
          if (encoding == null || encoding.getName().equals(ContentEncodingRepository.IDENTITY)) {
              return null;
          }
          String newPath = path + ".undertow.encoding." + encoding.getName();
          Resource preCompressed = encoded.getResource(newPath);
          if (preCompressed != null) {
              return new ContentEncodedResource(preCompressed, encoding.getName());
          }
          final LockKey key = new LockKey(path, encoding.getName());
          if (fileLocks.putIfAbsent(key, this) != null) {
              //another thread is already compressing
              //we don't do anything fancy here, just return and serve non-compressed content
              return null;
          }
          FileChannel targetFileChannel = null;
          FileChannel sourceFileChannel = null;
          try {
              //double check, the compressing thread could have finished just before we acquired the lock
              preCompressed = encoded.getResource(newPath);
              if (preCompressed != null) {
                  return new ContentEncodedResource(preCompressed, encoding.getName());
              }
  
              final Path finalTarget = encodedResourcesRoot.resolve(newPath);
              final Path tempTarget = encodedResourcesRoot.resolve(newPath);
  
              //horrible hack to work around XNIO issue
              OutputStream tmp = Files.newOutputStream(tempTarget);
              try {
                  tmp.close();
              } finally {
                  IoUtils.safeClose(tmp);
              }
  
              targetFileChannel = FileChannel.open(tempTarget, StandardOpenOption.READ, StandardOpenOption.WRITE);
              sourceFileChannel = FileChannel.open(file, StandardOpenOption.READ);
  
              StreamSinkConduit conduit = encoding.getEncoding().getResponseWrapper().wrap(new ImmediateConduitFactory<StreamSinkConduit>(new FileConduitTarget(targetFileChannel, exchange)), exchange);
              final ConduitStreamSinkChannel targetChannel = new ConduitStreamSinkChannel(null, conduit);
              long transferred = sourceFileChannel.transferTo(0, resource.getContentLength(), targetChannel);
              targetChannel.shutdownWrites();
              org.xnio.channels.Channels.flushBlocking(targetChannel);
              if (transferred != resource.getContentLength()) {
                  UndertowLogger.REQUEST_LOGGER.failedToWritePreCachedFile();
              }
              Files.move(tempTarget, finalTarget);
              encoded.invalidate(newPath);
              final Resource encodedResource = encoded.getResource(newPath);
              return new ContentEncodedResource(encodedResource, encoding.getName());
          } finally {
              IoUtils.safeClose(targetFileChannel);
              IoUtils.safeClose(sourceFileChannel);
              fileLocks.remove(key);
          }
      }