Program: 91931
Project: 91931
Buggy source:
/** 
 * Parses a   {@code "ProjectedCRS"} (WKT 2) element. The syntax is given by<a href="http://docs.opengeospatial.org/is/12-063r5/12-063r5.html#57">WKT 2 specification §9</a>. The legacy WKT 1 specification was: {@preformat text}PROJCS["<name>", <geographic cs>, <projection>,  <parameter>,}*, <linear unit> {,<twin axes>}{,<authority>}] }
 * @param mode      {@link #FIRST},   {@link #OPTIONAL} or {@link #MANDATORY}.
 * @param parent    The parent element.
 * @param isBaseCRS {@code true} if parsing the CRS inside a {@code DerivedCRS}.
 * @return The {@code "ProjectedCRS"} element as a {@link ProjectedCRS} object.
 * @throws ParseException if the {@code "ProjectedCRS"} element can not be parsed.
 */
private ProjectedCRS parseProjectedCRS(final int mode,final Element parent,final boolean isBaseCRS) throws ParseException {
  final Element element=parent.pullElement(mode,isBaseCRS ? new String[]{WKTKeywords.BaseProjCRS} : new String[]{WKTKeywords.ProjectedCRS,WKTKeywords.ProjCRS,WKTKeywords.ProjCS});
  if (element == null) {
    return null;
  }
  final boolean isWKT1=element.getKeywordIndex() == 2;
  final String name=element.pullString("String_Node_Str");
  final SingleCRS geoCRS=parseGeodeticCRS(MANDATORY,element,2,WKTKeywords.ellipsoidal);
  if (!(geoCRS instanceof GeographicCRS)) {
    throw new LocalizedParseException(errorLocale,Errors.Keys.IllegalCRSType_1,new Object[]{geoCRS.getClass()},element.offset);
  }
  Unit<Length> csUnit=parseScaledUnit(element,WKTKeywords.LengthUnit,SI.METRE);
  final Unit<Length> linearUnit;
  final Unit<Angle> angularUnit;
  if (isWKT1 && usesCommonUnits) {
    linearUnit=SI.METRE;
    angularUnit=NonSI.DEGREE_ANGLE;
  }
 else {
    linearUnit=csUnit;
    angularUnit=AxisDirections.getAngularUnit(geoCRS.getCoordinateSystem(),NonSI.DEGREE_ANGLE);
  }
  final Conversion conversion=parseDerivingConversion(MANDATORY,element,isWKT1 ? null : WKTKeywords.Conversion,linearUnit,angularUnit);
  if (csUnit == null && isBaseCRS) {
    csUnit=SI.METRE;
  }
  final CoordinateSystem cs;
  try {
    cs=parseCoordinateSystem(element,WKTKeywords.Cartesian,2,isWKT1,csUnit,geoCRS.getDatum());
    final Map<String,?> properties=parseMetadataAndClose(element,name,conversion);
    if (cs instanceof CartesianCS) {
      return crsFactory.createProjectedCRS(properties,(GeographicCRS)geoCRS,conversion,(CartesianCS)cs);
    }
  }
 catch (  FactoryException exception) {
    throw element.parseFailed(exception);
  }
  throw element.illegalCS(cs);
}

Fixed version (ground truth):
/** 
 * Parses a   {@code "ProjectedCRS"} (WKT 2) element. The syntax is given by<a href="http://docs.opengeospatial.org/is/12-063r5/12-063r5.html#57">WKT 2 specification §9</a>. The legacy WKT 1 specification was: {@preformat wkt}PROJCS["<name>", <geographic cs>, <projection>,  <parameter>,}*, <linear unit> {,<twin axes>}{,<authority>}] }
 * @param mode      {@link #FIRST},   {@link #OPTIONAL} or {@link #MANDATORY}.
 * @param parent    The parent element.
 * @param isBaseCRS {@code true} if parsing the CRS inside a {@code DerivedCRS}.
 * @return The {@code "ProjectedCRS"} element as a {@link ProjectedCRS} object.
 * @throws ParseException if the {@code "ProjectedCRS"} element can not be parsed.
 */
private ProjectedCRS parseProjectedCRS(final int mode,final Element parent,final boolean isBaseCRS) throws ParseException {
  final Element element=parent.pullElement(mode,isBaseCRS ? new String[]{WKTKeywords.BaseProjCRS} : new String[]{WKTKeywords.ProjectedCRS,WKTKeywords.ProjCRS,WKTKeywords.ProjCS});
  if (element == null) {
    return null;
  }
  final boolean isWKT1=element.getKeywordIndex() == 2;
  final String name=element.pullString("String_Node_Str");
  final SingleCRS geoCRS=parseGeodeticCRS(MANDATORY,element,2,WKTKeywords.ellipsoidal);
  if (!(geoCRS instanceof GeographicCRS)) {
    throw new LocalizedParseException(errorLocale,Errors.Keys.IllegalCRSType_1,new Object[]{geoCRS.getClass()},element.offset);
  }
  Unit<Length> csUnit=parseScaledUnit(element,WKTKeywords.LengthUnit,SI.METRE);
  final Unit<Length> linearUnit;
  final Unit<Angle> angularUnit;
  if (isWKT1 && usesCommonUnits) {
    linearUnit=SI.METRE;
    angularUnit=NonSI.DEGREE_ANGLE;
  }
 else {
    linearUnit=csUnit;
    angularUnit=AxisDirections.getAngularUnit(geoCRS.getCoordinateSystem(),NonSI.DEGREE_ANGLE);
  }
  final Conversion conversion=parseDerivingConversion(MANDATORY,element,isWKT1 ? null : WKTKeywords.Conversion,linearUnit,angularUnit);
  if (csUnit == null && isBaseCRS) {
    csUnit=SI.METRE;
  }
  final CoordinateSystem cs;
  try {
    cs=parseCoordinateSystem(element,WKTKeywords.Cartesian,2,isWKT1,csUnit,geoCRS.getDatum());
    final Map<String,?> properties=parseMetadataAndClose(element,name,conversion);
    if (cs instanceof CartesianCS) {
      return crsFactory.createProjectedCRS(properties,(GeographicCRS)geoCRS,conversion,(CartesianCS)cs);
    }
  }
 catch (  FactoryException exception) {
    throw element.parseFailed(exception);
  }
  throw element.illegalCS(cs);
}