Program: 35861
Project: 35861
Buggy source:
private final void renderResource(String relUrl,Output output,Context context) throws IOException, ResourceNotFoundException {
  String httpUrl=getUrlForHttpResource(relUrl,context);
  String fileUrl=getUrlForFileResource(relUrl,context);
  MultipleOutput multipleOutput=new MultipleOutput();
  multipleOutput.addOutput(output);
  MemoryResource cachedResource=null;
  try {
    if (useCache) {
      cachedResource=(MemoryResource)cache.getFromCache(httpUrl);
      cachedResource=(MemoryResource)cache.getFromCache(httpUrl,cacheRefreshDelay);
    }
    if (cachedResource == null)     throw new NeedsRefreshException(null);
    cachedResource.render(multipleOutput);
  }
 catch (  NeedsRefreshException e) {
    boolean cacheUpdated=false;
    try {
      MemoryOutput memoryOutput=null;
      HttpResource httpResource=null;
      if (baseURL != null)       httpResource=getResourceFromHttp(httpUrl);
      if (httpResource != null) {
        if (useCache) {
          memoryOutput=new MemoryOutput(cacheMaxFileSize);
          multipleOutput.addOutput(memoryOutput);
        }
        if (putInCache)         multipleOutput.addOutput(new FileOutput(fileUrl));
        httpResource.render(multipleOutput);
      }
 else       if (cachedResource != null) {
        cachedResource.render(multipleOutput);
      }
 else {
        FileResource fileResource=getResourceFromLocal(fileUrl);
        if (fileResource == null)         throw new ResourceNotFoundException(relUrl);
        if (useCache) {
          memoryOutput=new MemoryOutput(cacheMaxFileSize);
          multipleOutput.addOutput(memoryOutput);
        }
        fileResource.render(multipleOutput);
      }
      if (memoryOutput != null) {
        cachedResource=memoryOutput.toResource();
        cache.putInCache(httpUrl,cachedResource);
        cacheUpdated=true;
      }
    }
  finally {
      if (useCache && !cacheUpdated)       cache.cancelUpdate(httpUrl);
    }
  }
}

Fixed version (ground truth):
private final void renderResource(String relUrl,Output output,Context context) throws IOException, ResourceNotFoundException {
  String httpUrl=getUrlForHttpResource(relUrl,context);
  String fileUrl=getUrlForFileResource(relUrl,context);
  MultipleOutput multipleOutput=new MultipleOutput();
  multipleOutput.addOutput(output);
  MemoryResource cachedResource=null;
  HttpResource httpResource=null;
  FileResource fileResource=null;
  try {
    if (useCache) {
      cachedResource=(MemoryResource)cache.getFromCache(httpUrl);
      cachedResource=(MemoryResource)cache.getFromCache(httpUrl,cacheRefreshDelay);
    }
    if (cachedResource == null)     throw new NeedsRefreshException(null);
    cachedResource.render(multipleOutput);
  }
 catch (  NeedsRefreshException e) {
    boolean cacheUpdated=false;
    try {
      MemoryOutput memoryOutput=null;
      if (baseURL != null)       httpResource=getResourceFromHttp(httpUrl);
      if (httpResource != null) {
        if (useCache) {
          memoryOutput=new MemoryOutput(cacheMaxFileSize);
          multipleOutput.addOutput(memoryOutput);
        }
        if (putInCache)         multipleOutput.addOutput(new FileOutput(fileUrl));
        httpResource.render(multipleOutput);
      }
 else       if (cachedResource != null) {
        cachedResource.render(multipleOutput);
      }
 else {
        fileResource=getResourceFromLocal(fileUrl);
        if (fileResource == null)         throw new ResourceNotFoundException(relUrl);
        if (useCache) {
          memoryOutput=new MemoryOutput(cacheMaxFileSize);
          multipleOutput.addOutput(memoryOutput);
        }
        fileResource.render(multipleOutput);
      }
      if (memoryOutput != null) {
        cachedResource=memoryOutput.toResource();
        cache.putInCache(httpUrl,cachedResource);
        cacheUpdated=true;
        if (cachedResource != null)         cachedResource.release();
        if (httpResource != null)         httpResource.release();
        if (fileResource != null)         fileResource.release();
      }
    }
  finally {
      if (useCache && !cacheUpdated)       cache.cancelUpdate(httpUrl);
    }
  }
}