Program: 19228
Project: 19228
Buggy source:
public void createDataStructs(Map<String,Map<String,JsonFormatterData>> stationData,Map<String,Integer> stationToNum){
  List<String> obsProps=handler.getRequestedObservedProperties();
  String time_keyname=baseCDMClass.TIME_STR.replace("String_Node_Str","String_Node_Str");
  String station_keyname=baseCDMClass.STATION_STR.replace("String_Node_Str","String_Node_Str");
  String binKeyname=TimeSeriesProfile.BIN_STR.replace("String_Node_Str","String_Node_Str");
  Map<String,List<Double>> heightMap=new HashMap<String,List<Double>>();
  boolean isProfile=handler.getCDMDataset() instanceof TimeSeriesProfile;
  boolean is3dGrid=this.handler.is3dGrid(this.handler.getCDMDataset().getStationName(0));
  for (int p=0; p < handler.getProcedures().length; p++) {
    String keyVals=handler.getValueBlockForAllObs(BLOCK_SEPERATOR,DECIMAL_SEPERATOR,TOKEN_SEPERATOR,p);
    for (    String block : keyVals.split(BLOCK_SEPERATOR)) {
      String blockAr[]=block.split(TOKEN_SEPERATOR);
      String station=null;
      String time=null;
      int stationNum=-1;
      int bin=0;
      for (      String token : blockAr) {
        String[] tokenSplit=token.split("String_Node_Str");
        if (tokenSplit[0].equals(station_keyname)) {
          stationNum=Integer.parseInt(tokenSplit[1]);
          station=this.handler.stationToFieldName(this.handler.getProcedures()[stationNum]) + "String_Node_Str";
        }
 else         if (tokenSplit[0].equals(time_keyname)) {
          time=tokenSplit[1];
        }
 else         if (tokenSplit[0].equals(binKeyname)) {
          bin=Integer.parseInt(tokenSplit[1]);
        }
      }
      if (station == null || time == null)       continue;
      for (      String token : blockAr) {
        String[] tokenSplit=token.split("String_Node_Str");
        String var=tokenSplit[0];
        if (var.equals(time_keyname) || var.equals(station_keyname)) {
          continue;
        }
        if (obsProps.contains(var) && tokenSplit.length > 1) {
          String varValue=tokenSplit[1];
          station=station + var;
          if (!stationData.containsKey(station)) {
            stationToNum.put(station,stationNum);
            stationData.put(station,new HashMap<String,JsonFormatterData>());
          }
          String varStandard=handler.getVariableStandardName(var);
          if (varStandard.equals(BaseRequestHandler.UNKNOWN)) {
            varStandard=station;
          }
          Map<String,JsonFormatterData> cData=stationData.get(station);
          if (!cData.containsKey(varStandard)) {
            String heightUnits=null;
            if (isProfile) {
              heightUnits=((TimeSeriesProfile)handler.getCDMDataset()).getHeightAxisUnits();
              heightMap.put(station,((TimeSeriesProfile)handler.getCDMDataset()).getProfileHeightsForStation(String.valueOf(stationNum)));
            }
 else             if (is3dGrid) {
              Grid grid=((Grid)this.handler.getCDMDataset());
              heightMap.put(station,grid.getDepths(var));
              heightUnits=grid.getDepthUnits(var);
            }
            JsonFormatterData jdata=new JsonFormatterData(varStandard,(handler.getUnitsString(var)),heightUnits);
            cData.put(varStandard,jdata);
          }
          JsonFormatterData data=cData.get(varStandard);
          data.getTimeValues().add(time);
          data.getDataValues().add(varValue);
          if (isProfile || is3dGrid)           data.getHeightValues().add(heightMap.get(station).get(bin));
        }
      }
    }
  }
}

Fixed version (ground truth):
public void createDataStructs(Map<String,Map<String,JsonFormatterData>> stationData,Map<String,Integer> stationToNum){
  List<String> obsProps=handler.getRequestedObservedProperties();
  String time_keyname=baseCDMClass.TIME_STR.replace("String_Node_Str","String_Node_Str");
  String station_keyname=baseCDMClass.STATION_STR.replace("String_Node_Str","String_Node_Str");
  String binKeyname=TimeSeriesProfile.BIN_STR.replace("String_Node_Str","String_Node_Str");
  Map<String,List<Double>> heightMap=new HashMap<String,List<Double>>();
  boolean isProfile=handler.getCDMDataset() instanceof TimeSeriesProfile;
  boolean is3dGrid=this.handler.is3dGrid(this.handler.getCDMDataset().getStationName(0));
  int cStat=0;
  for (int p=0; p < handler.getProcedures().length; p++) {
    String keyVals=handler.getValueBlockForAllObs(BLOCK_SEPERATOR,DECIMAL_SEPERATOR,TOKEN_SEPERATOR,p);
    for (    String block : keyVals.split(BLOCK_SEPERATOR)) {
      String blockAr[]=block.split(TOKEN_SEPERATOR);
      String station="String_Node_Str";
      String time=null;
      int stationNum=-1;
      String currDepth=null;
      int bin=0;
      for (      String token : blockAr) {
        String[] tokenSplit=token.split("String_Node_Str");
        if (tokenSplit[0].equals(station_keyname)) {
          stationNum=Integer.parseInt(tokenSplit[1]);
          station=this.handler.stationToFieldName(this.handler.getProcedures()[stationNum]);
        }
 else         if (tokenSplit[0].equals(time_keyname)) {
          time=tokenSplit[1];
        }
 else         if (tokenSplit[0].equals(binKeyname)) {
          bin=Integer.parseInt(tokenSplit[1]);
        }
 else         if (tokenSplit[0].equals(this.handler.getDepthAxisName())) {
          currDepth=tokenSplit[1];
        }
      }
      if (time == null)       continue;
      for (      String token : blockAr) {
        String[] tokenSplit=token.split("String_Node_Str");
        String var=tokenSplit[0];
        if (var.equals(time_keyname) || var.equals(station_keyname)) {
          continue;
        }
        if (obsProps.contains(var) && tokenSplit.length > 1) {
          String varValue=tokenSplit[1];
          station=station + "String_Node_Str" + var;
          if (!stationData.containsKey(station)) {
            if (stationNum != -1)             stationToNum.put(station,stationNum);
 else {
              stationToNum.put(station,cStat);
              cStat++;
            }
            stationData.put(station,new HashMap<String,JsonFormatterData>());
          }
          String varStandard=handler.getVariableStandardName(var);
          if (varStandard.equals(BaseRequestHandler.UNKNOWN)) {
            varStandard=station;
          }
          Map<String,JsonFormatterData> cData=stationData.get(station);
          if (!cData.containsKey(varStandard)) {
            String heightUnits=null;
            if (isProfile) {
              heightUnits=((TimeSeriesProfile)handler.getCDMDataset()).getHeightAxisUnits();
              heightMap.put(station,((TimeSeriesProfile)handler.getCDMDataset()).getProfileHeightsForStation(stationNum));
            }
 else             if (is3dGrid) {
              Grid grid=((Grid)this.handler.getCDMDataset());
              heightMap.put(station,grid.getDepths(var));
              heightUnits=grid.getDepthUnits(var);
            }
 else {
              heightUnits=null;
              CoordinateAxis zAxis=this.handler.getNetCDFDataset().findCoordinateAxis(AxisType.Height);
              if (zAxis != null && zAxis.getSize() > 1) {
                heightUnits=this.handler.getDepthUnits();
              }
            }
            JsonFormatterData jdata=new JsonFormatterData(varStandard,(handler.getUnitsString(var)),heightUnits);
            cData.put(varStandard,jdata);
          }
          JsonFormatterData data=cData.get(varStandard);
          data.getTimeValues().add(time);
          data.getDataValues().add(varValue);
          if (isProfile || is3dGrid)           data.getHeightValues().add(heightMap.get(station).get(bin));
 else           if (currDepth != null && data.heightValues != null)           data.heightValues.add(Double.valueOf(currDepth));
        }
      }
    }
  }
}