Program: 91949
Project: 91949
Buggy source:
/** 
 * Prints metadata or CRS information.
 * @throws DataStoreException If an error occurred while reading the file.
 * @throws JAXBException If an error occurred while producing the XML output.
 * @throws IOException Should never happen, since we are appending to a print writer.
 */
@Override public int run() throws InvalidOptionException, DataStoreException, JAXBException, IOException {
  Convention convention=null;
  final Format outputFormat;
  final String format=options.get(Option.FORMAT);
  if (format == null || format.equalsIgnoreCase("String_Node_Str")) {
    if (isCRS) {
      outputFormat=Format.WKT;
      convention=Convention.WKT2_SIMPLIFIED;
    }
 else {
      outputFormat=Format.TEXT;
    }
  }
 else   if (isCRS && (format.equalsIgnoreCase("String_Node_Str") || format.equalsIgnoreCase("String_Node_Str"))) {
    outputFormat=Format.WKT;
    convention=Convention.WKT2;
  }
 else   if (isCRS && format.equalsIgnoreCase("String_Node_Str")) {
    outputFormat=Format.WKT;
    convention=Convention.WKT1;
  }
 else   if (format.equalsIgnoreCase("String_Node_Str")) {
    outputFormat=Format.XML;
  }
 else {
    throw new InvalidOptionException(Errors.format(Errors.Keys.IllegalOptionValue_2,"String_Node_Str",format),format);
  }
  if (hasUnexpectedFileCount(1,1)) {
    return Command.INVALID_ARGUMENT_EXIT_CODE;
  }
  final Metadata metadata;
  final DataStore store=DataStores.open(files.get(0));
  try {
    metadata=store.getMetadata();
  }
  finally {
    store.close();
  }
  if (metadata == null) {
    return 0;
  }
  Object object=metadata;
  if (isCRS) {
    boolean found=false;
    for (    final ReferenceSystem rs : metadata.getReferenceSystemInfo()) {
      if (rs instanceof CoordinateReferenceSystem) {
        object=(CoordinateReferenceSystem)rs;
        found=true;
        break;
      }
    }
    if (!found) {
      return 0;
    }
  }
switch (outputFormat) {
case TEXT:
{
      final TreeTable tree=MetadataStandard.ISO_19115.asTreeTable(metadata,ValueExistencePolicy.NON_EMPTY);
      final TreeTableFormat tf=new TreeTableFormat(locale,timezone);
      tf.setColumns(TableColumn.NAME,TableColumn.VALUE);
      tf.format(tree,out);
      break;
    }
case WKT:
{
    final WKTFormat f=new WKTFormat(locale,timezone);
    if (convention != null) {
      f.setConvention(convention);
    }
    if (colors) {
      f.setColors(Colors.DEFAULT);
    }
    f.format(object,out);
    out.println();
    break;
  }
case XML:
{
  final MarshallerPool pool=new MarshallerPool(null);
  final Marshaller marshaller=pool.acquireMarshaller();
  marshaller.setProperty(XML.LOCALE,locale);
  marshaller.setProperty(XML.TIMEZONE,timezone);
  if (isConsole()) {
    marshaller.marshal(object,out);
  }
 else {
    out.flush();
    marshaller.setProperty(Marshaller.JAXB_ENCODING,encoding.name());
    marshaller.marshal(object,System.out);
    System.out.flush();
  }
  break;
}
}
out.flush();
return 0;
}

Fixed version (ground truth):
/** 
 * Prints metadata or CRS information.
 * @throws DataStoreException If an error occurred while reading the file.
 * @throws JAXBException If an error occurred while producing the XML output.
 * @throws IOException Should never happen, since we are appending to a print writer.
 */
@Override @SuppressWarnings("String_Node_Str") public int run() throws InvalidOptionException, DataStoreException, JAXBException, IOException {
  Convention convention=null;
  final Format outputFormat;
  final String format=options.get(Option.FORMAT);
  if (format == null || format.equalsIgnoreCase("String_Node_Str")) {
    if (isCRS) {
      outputFormat=Format.WKT;
      convention=Convention.WKT2_SIMPLIFIED;
    }
 else {
      outputFormat=Format.TEXT;
    }
  }
 else   if (isCRS && (format.equalsIgnoreCase("String_Node_Str") || format.equalsIgnoreCase("String_Node_Str"))) {
    outputFormat=Format.WKT;
    convention=Convention.WKT2;
  }
 else   if (isCRS && format.equalsIgnoreCase("String_Node_Str")) {
    outputFormat=Format.WKT;
    convention=Convention.WKT1;
  }
 else   if (format.equalsIgnoreCase("String_Node_Str")) {
    outputFormat=Format.XML;
  }
 else {
    throw new InvalidOptionException(Errors.format(Errors.Keys.IllegalOptionValue_2,"String_Node_Str",format),format);
  }
  Object metadata;
  if (useStandardInput()) {
    DataStore store=DataStores.open(System.in);
    try {
      metadata=store.getMetadata();
    }
  finally {
      store.close();
    }
  }
 else {
    if (hasUnexpectedFileCount(1,1)) {
      return Command.INVALID_ARGUMENT_EXIT_CODE;
    }
    DataStore store=DataStores.open(files.get(0));
    try {
      metadata=store.getMetadata();
    }
  finally {
      store.close();
    }
  }
  if (metadata == null) {
    return 0;
  }
  if (isCRS && (metadata instanceof Metadata)) {
    boolean found=false;
    for (    final ReferenceSystem rs : ((Metadata)metadata).getReferenceSystemInfo()) {
      if (rs instanceof CoordinateReferenceSystem) {
        metadata=rs;
        found=true;
        break;
      }
    }
    if (!found) {
      return 0;
    }
  }
switch (outputFormat) {
case TEXT:
{
      final TreeTable tree=MetadataStandard.ISO_19115.asTreeTable(metadata,ValueExistencePolicy.NON_EMPTY);
      final TreeTableFormat tf=new TreeTableFormat(locale,timezone);
      tf.setColumns(TableColumn.NAME,TableColumn.VALUE);
      tf.format(tree,out);
      break;
    }
case WKT:
{
    final WKTFormat f=new WKTFormat(locale,timezone);
    if (convention != null) {
      f.setConvention(convention);
    }
    if (colors) {
      f.setColors(Colors.DEFAULT);
    }
    f.format(metadata,out);
    out.println();
    break;
  }
case XML:
{
  final MarshallerPool pool=new MarshallerPool(null);
  final Marshaller marshaller=pool.acquireMarshaller();
  marshaller.setProperty(XML.LOCALE,locale);
  marshaller.setProperty(XML.TIMEZONE,timezone);
  if (isConsole()) {
    marshaller.marshal(metadata,out);
  }
 else {
    out.flush();
    marshaller.setProperty(Marshaller.JAXB_ENCODING,encoding.name());
    marshaller.marshal(metadata,System.out);
    System.out.flush();
  }
  break;
}
}
out.flush();
return 0;
}