Program: 145540
Project: 145540
Buggy source:
/** 
 * Loads a resource's bytes either from disk or from datatbase.
 * @param aResourceId An relative path to the resource
 * @return Bytes for resource
 * @throws Exception If some error occurs when reading the resource
 */
public static byte[] load(String aResourceId) throws Exception {
  if (aResourceId != null && !aResourceId.isEmpty()) {
    Matcher htppMatcher=pattern.matcher(aResourceId);
    if (htppMatcher.matches()) {
      URL url=new URL(aResourceId);
      try {
        try (InputStream is=url.openStream()){
          return BinaryUtils.readStream(is,-1);
        }
       }
 catch (      IOException ex) {
        url=encodeUrl(url);
        try (InputStream is=url.openStream()){
          return BinaryUtils.readStream(is,-1);
        }
       }
    }
 else {
      if (cache == null) {
        throw new IllegalStateException("String_Node_Str");
      }
      String resourceId=translateResourcePath(aResourceId);
      ApplicationElement appElement=cache.get(resourceId);
      if (appElement != null) {
        if (appElement.getType() == ClientConstants.ET_RESOURCE) {
          if (!cache.isActual(appElement.getId(),appElement.getTxtContentLength(),appElement.getTxtCrc32())) {
            cache.remove(appElement.getId());
            appElement=cache.get(resourceId);
          }
        }
 else {
          throw new NotResourceException(resourceId);
        }
      }
      if (appElement != null && appElement.getType() == ClientConstants.ET_RESOURCE) {
        return appElement.getBinaryContent();
      }
 else {
        return null;
      }
    }
  }
 else {
    return null;
  }
}

Fixed version (ground truth):
/** 
 * Loads a resource's bytes either from disk or from datatbase.
 * @param aResourceId An relative path to the resource
 * @return Bytes for resource
 * @throws Exception If some error occurs when reading the resource
 */
public static byte[] load(String aResourceId) throws Exception {
  if (aResourceId != null && !aResourceId.isEmpty()) {
    Matcher htppMatcher=pattern.matcher(aResourceId);
    if (htppMatcher.matches()) {
      URL url=new URL(aResourceId);
      try {
        try (InputStream is=url.openStream()){
          return BinaryUtils.readStream(is,-1);
        }
       }
 catch (      IOException ex) {
        url=encodeUrl(url);
        try (InputStream is=url.openStream()){
          return BinaryUtils.readStream(is,-1);
        }
       }
    }
 else {
      if (cache == null) {
        throw new IllegalStateException("String_Node_Str");
      }
      String resourceId=translateResourcePath(aResourceId);
      ApplicationElement appElement=cache.get(resourceId);
      if (appElement != null) {
        if (appElement.getType() == ClientConstants.ET_RESOURCE) {
          if (!cache.isActual(appElement.getId(),appElement.getTxtContentLength(),appElement.getTxtCrc32())) {
            cache.remove(appElement.getId());
            appElement=cache.get(resourceId);
          }
        }
 else {
          throw new NotResourceException(resourceId);
        }
      }
      if (appElement != null && appElement.getType() == ClientConstants.ET_RESOURCE) {
        return appElement.getBinaryContent();
      }
 else {
        throw new IllegalArgumentException(String.format("String_Node_Str",aResourceId));
      }
    }
  }
 else {
    return null;
  }
}