Program: 188823
Project: 188823
Buggy source:
/** 
 * Validates descriptive medatada (e.g. against its schema, but other strategies may be used)
 */
public static boolean isDescriptiveMetadataValid(ModelService model,DescriptiveMetadata metadata) throws ModelServiceException {
  boolean valid=false;
  try {
    StoragePath storagePath=metadata.getStoragePath();
    Binary binary=model.getStorage().getBinary(storagePath);
    InputStream inputStream=binary.getContent().createInputStream();
    String filename=binary.getStoragePath().getName();
    ClassLoader classLoader=SolrUtils.class.getClassLoader();
    InputStream schemaStream=classLoader.getResourceAsStream("String_Node_Str" + filename + "String_Node_Str");
    if (schemaStream == null) {
      throw new ModelServiceException("String_Node_Str" + filename,ModelServiceException.INTERNAL_SERVER_ERROR);
    }
    Source xmlFile=new StreamSource(inputStream);
    SchemaFactory schemaFactory=SchemaFactory.newInstance(W3C_XML_SCHEMA_NS_URI);
    Schema schema=schemaFactory.newSchema(new StreamSource(schemaStream));
    Validator validator=schema.newValidator();
    try {
      validator.validate(xmlFile);
      valid=true;
    }
 catch (    SAXException e) {
      LOGGER.error("String_Node_Str" + metadata.getStoragePath().asString());
    }
  }
 catch (  StorageActionException|SAXException|IOException e) {
    throw new ModelServiceException("String_Node_Str" + metadata.getStoragePath().asString(),ModelServiceException.INTERNAL_SERVER_ERROR,e);
  }
  return valid;
}

Fixed version (ground truth):
/** 
 * Validates descriptive medatada (e.g. against its schema, but other strategies may be used)
 * @param failIfNoSchema
 */
public static boolean isDescriptiveMetadataValid(ModelService model,DescriptiveMetadata metadata,boolean failIfNoSchema) throws ModelServiceException {
  boolean valid;
  try {
    StoragePath storagePath=metadata.getStoragePath();
    Binary binary=model.getStorage().getBinary(storagePath);
    InputStream inputStream=binary.getContent().createInputStream();
    String filename=binary.getStoragePath().getName();
    ClassLoader classLoader=SolrUtils.class.getClassLoader();
    InputStream schemaStream=classLoader.getResourceAsStream("String_Node_Str" + filename + "String_Node_Str");
    if (schemaStream != null) {
      Source xmlFile=new StreamSource(inputStream);
      SchemaFactory schemaFactory=SchemaFactory.newInstance(W3C_XML_SCHEMA_NS_URI);
      Schema schema=schemaFactory.newSchema(new StreamSource(schemaStream));
      Validator validator=schema.newValidator();
      try {
        validator.validate(xmlFile);
        valid=true;
      }
 catch (      SAXException e) {
        valid=false;
        LOGGER.error("String_Node_Str" + metadata.getStoragePath().asString());
      }
    }
 else {
      if (failIfNoSchema) {
        throw new ModelServiceException("String_Node_Str" + filename,ModelServiceException.INTERNAL_SERVER_ERROR);
      }
 else {
        valid=true;
      }
    }
  }
 catch (  StorageServiceException|SAXException|IOException e) {
    throw new ModelServiceException("String_Node_Str" + metadata.getStoragePath().asString(),ModelServiceException.INTERNAL_SERVER_ERROR,e);
  }
  return valid;
}