Program: 35862
Project: 35862
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;
  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)       if (cachedResource != null)       cache.putInCache(httpUrl,cachedResource);
 else       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) {
    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();
        if (cachedResource != null)         cachedResource.release();
        if (httpResource != null)         httpResource.release();
        if (fileResource != null)         fileResource.release();
      }
    }
  finally {
      if (useCache)       if (cachedResource != null)       cache.putInCache(httpUrl,cachedResource);
 else       cache.cancelUpdate(httpUrl);
    }
  }
}