Program: 35445
Project: 35445
Buggy source:
@Override public void process(HttpServletResponse response) throws Exception {
  String reqMethod=_request.getMethod();
  GeocodingRequest req=null;
switch (reqMethod) {
case "String_Node_Str":
    req=new GeocodingRequest();
  String value=_request.getParameter("String_Node_Str");
if (!Helper.isEmpty(value)) req.setQuery(value);
req.setLanguage(_request.getParameter("String_Node_Str"));
boolean inverseXY=true;
value=_request.getParameter("String_Node_Str");
if (Helper.isEmpty(value)) {
value=_request.getParameter("String_Node_Str");
inverseXY=false;
}
if (!Helper.isEmpty(value)) {
String[] coords=value.split("String_Node_Str");
if (coords.length != 2) throw new StatusCodeException(StatusCode.BAD_REQUEST,GeocodingErrorCodes.MISSING_PARAMETER,"String_Node_Str");
try {
if (inverseXY) req.setLocation(new Coordinate(Double.parseDouble(coords[1]),Double.parseDouble(coords[0])));
 else req.setLocation(new Coordinate(Double.parseDouble(coords[0]),Double.parseDouble(coords[1])));
}
 catch (NumberFormatException ex) {
throw new StatusCodeException(StatusCode.BAD_REQUEST,GeocodingErrorCodes.INVALID_PARAMETER_FORMAT,"String_Node_Str");
}
req.setLanguage(null);
req.setLimit(1);
}
 else if (Helper.isEmpty(req.getQuery())) {
throw new MissingParameterException(GeocodingErrorCodes.MISSING_PARAMETER,"String_Node_Str");
}
value=_request.getParameter("String_Node_Str");
if (!Helper.isEmpty(value)) {
int limit=Integer.parseInt(value);
if (limit > GeocodingServiceSettings.getResponseLimit()) throw new ParameterOutOfRangeException(GeocodingErrorCodes.PARAMETER_VALUE_EXCEEDS_MAXIMUM,"String_Node_Str",value,Integer.toString(GeocodingServiceSettings.getResponseLimit()));
req.setLimit(limit);
}
value=_request.getParameter("String_Node_Str");
if (!Helper.isEmpty(value)) {
if ("String_Node_Str".equalsIgnoreCase(value)) {
value=_request.getParameter("String_Node_Str");
String[] coords=value.split("String_Node_Str");
if (coords == null || coords.length != 4) throw new StatusCodeException(StatusCode.BAD_REQUEST,GeocodingErrorCodes.INVALID_PARAMETER_VALUE,"String_Node_Str");
Envelope bbox=null;
try {
bbox=new Envelope(Double.parseDouble(coords[0]),Double.parseDouble(coords[2]),Double.parseDouble(coords[1]),Double.parseDouble(coords[3]));
}
 catch (NumberFormatException ex) {
throw new StatusCodeException(StatusCode.BAD_REQUEST,GeocodingErrorCodes.INVALID_PARAMETER_FORMAT,"String_Node_Str");
}
RectSearchBoundary rsb=new RectSearchBoundary(bbox);
req.setBoundary(rsb);
}
 else if ("String_Node_Str".equalsIgnoreCase(value)) {
value=_request.getParameter("String_Node_Str");
String[] values=value.split("String_Node_Str");
if (values == null || values.length != 3) throw new StatusCodeException(StatusCode.BAD_REQUEST,GeocodingErrorCodes.INVALID_PARAMETER_VALUE,"String_Node_Str");
CircleSearchBoundary csb=new CircleSearchBoundary(Double.parseDouble(values[0]),Double.parseDouble(values[1]),Double.parseDouble(values[2]));
req.setBoundary(csb);
}
}
value=_request.getParameter("String_Node_Str");
if (!Helper.isEmpty(value)) req.setId(value);
break;
case "String_Node_Str":
throw new StatusCodeException(StatusCode.METHOD_NOT_ALLOWED,GeocodingErrorCodes.UKNOWN,"String_Node_Str");
default :
throw new StatusCodeException(StatusCode.METHOD_NOT_ALLOWED,GeocodingErrorCodes.UKNOWN,"String_Node_Str");
}
if (!req.isValid()) throw new StatusCodeException(StatusCode.BAD_REQUEST,GeocodingErrorCodes.UKNOWN,"String_Node_Str");
try {
Geocoder geocoder=GeocoderFactory.createGeocoder(GeocodingServiceSettings.getGeocoderName(),GeocodingServiceSettings.getGeocodingURL(),GeocodingServiceSettings.getReverseGeocodingURL(),GeocodingServiceSettings.getUserAgent());
if (req.getLocation() != null) {
Coordinate c=req.getLocation();
GeocodingResult[] gresults=geocoder.reverseGeocode(c.x,c.y,req.getLimit());
writeGeocodingResponse(response,req,gresults);
}
 else {
if (Helper.isEmpty(req.getQuery())) throw new MissingParameterException(GeocodingErrorCodes.MISSING_PARAMETER,"String_Node_Str");
GeocodingResult[] gresults=geocoder.geocode(req.getQuery(),req.getLanguage(),req.getBoundary(),req.getLimit());
writeGeocodingResponse(response,req,gresults);
}
}
 catch (Exception ex) {
throw new InternalServerException(GeocodingErrorCodes.UKNOWN);
}
}

Fixed version (ground truth):
@Override public void process(HttpServletResponse response) throws Exception {
  String reqMethod=_request.getMethod();
  GeocodingRequest req=null;
switch (reqMethod) {
case "String_Node_Str":
    req=new GeocodingRequest();
  String value=_request.getParameter("String_Node_Str");
if (!Helper.isEmpty(value)) req.setQuery(value);
req.setLanguage(_request.getParameter("String_Node_Str"));
boolean inverseXY=true;
value=_request.getParameter("String_Node_Str");
if (Helper.isEmpty(value)) {
value=_request.getParameter("String_Node_Str");
inverseXY=false;
}
if (!Helper.isEmpty(value)) {
String[] coords=value.split("String_Node_Str");
if (coords.length != 2) throw new ParameterValueException(GeocodingErrorCodes.INVALID_PARAMETER_FORMAT,"String_Node_Str");
try {
if (inverseXY) req.setLocation(new Coordinate(Double.parseDouble(coords[1]),Double.parseDouble(coords[0])));
 else req.setLocation(new Coordinate(Double.parseDouble(coords[0]),Double.parseDouble(coords[1])));
}
 catch (NumberFormatException ex) {
throw new ParameterValueException(GeocodingErrorCodes.INVALID_PARAMETER_VALUE,"String_Node_Str");
}
req.setLanguage(null);
req.setLimit(1);
}
 else if (Helper.isEmpty(req.getQuery())) {
throw new MissingParameterException(GeocodingErrorCodes.MISSING_PARAMETER,"String_Node_Str");
}
value=_request.getParameter("String_Node_Str");
if (!Helper.isEmpty(value)) {
int limit=1;
try {
limit=Integer.parseInt(value);
}
 catch (NumberFormatException nfex) {
throw new ParameterValueException(GeocodingErrorCodes.INVALID_PARAMETER_VALUE,"String_Node_Str");
}
if (limit > GeocodingServiceSettings.getResponseLimit()) throw new ParameterOutOfRangeException(GeocodingErrorCodes.PARAMETER_VALUE_EXCEEDS_MAXIMUM,"String_Node_Str",value,Integer.toString(GeocodingServiceSettings.getResponseLimit()));
req.setLimit(limit);
}
value=_request.getParameter("String_Node_Str");
if (!Helper.isEmpty(value)) {
if ("String_Node_Str".equalsIgnoreCase(value)) {
value=_request.getParameter("String_Node_Str");
if (Helper.isEmpty(value)) throw new MissingParameterException(GeocodingErrorCodes.MISSING_PARAMETER,"String_Node_Str");
String[] coords=value.split("String_Node_Str");
if (coords == null || coords.length != 4) throw new ParameterValueException(GeocodingErrorCodes.INVALID_PARAMETER_VALUE,"String_Node_Str");
Envelope bbox=null;
try {
bbox=new Envelope(Double.parseDouble(coords[0]),Double.parseDouble(coords[2]),Double.parseDouble(coords[1]),Double.parseDouble(coords[3]));
}
 catch (NumberFormatException ex) {
throw new ParameterValueException(GeocodingErrorCodes.INVALID_PARAMETER_FORMAT,"String_Node_Str");
}
RectSearchBoundary rsb=new RectSearchBoundary(bbox);
req.setBoundary(rsb);
}
 else if ("String_Node_Str".equalsIgnoreCase(value)) {
value=_request.getParameter("String_Node_Str");
if (Helper.isEmpty(value)) throw new MissingParameterException(GeocodingErrorCodes.MISSING_PARAMETER,"String_Node_Str");
String[] values=value.split("String_Node_Str");
if (values == null || values.length != 3) throw new ParameterValueException(GeocodingErrorCodes.INVALID_PARAMETER_VALUE,"String_Node_Str");
CircleSearchBoundary csb=null;
try {
csb=new CircleSearchBoundary(Double.parseDouble(values[0]),Double.parseDouble(values[1]),Double.parseDouble(values[2]));
}
 catch (NumberFormatException nfex) {
throw new ParameterValueException(GeocodingErrorCodes.INVALID_PARAMETER_FORMAT,"String_Node_Str");
}
req.setBoundary(csb);
}
 else {
throw new ParameterValueException(GeocodingErrorCodes.INVALID_PARAMETER_VALUE,"String_Node_Str");
}
}
value=_request.getParameter("String_Node_Str");
if (!Helper.isEmpty(value)) req.setId(value);
break;
case "String_Node_Str":
throw new StatusCodeException(StatusCode.METHOD_NOT_ALLOWED,GeocodingErrorCodes.UKNOWN,"String_Node_Str");
default :
throw new StatusCodeException(StatusCode.METHOD_NOT_ALLOWED,GeocodingErrorCodes.UKNOWN,"String_Node_Str");
}
if (!req.isValid()) throw new StatusCodeException(StatusCode.BAD_REQUEST,GeocodingErrorCodes.UKNOWN,"String_Node_Str");
try {
Geocoder geocoder=GeocoderFactory.createGeocoder(GeocodingServiceSettings.getGeocoderName(),GeocodingServiceSettings.getGeocodingURL(),GeocodingServiceSettings.getReverseGeocodingURL(),GeocodingServiceSettings.getUserAgent());
if (req.getLocation() != null) {
Coordinate c=req.getLocation();
GeocodingResult[] gresults=geocoder.reverseGeocode(c.x,c.y,req.getLimit());
writeGeocodingResponse(response,req,gresults);
}
 else {
if (Helper.isEmpty(req.getQuery())) throw new MissingParameterException(GeocodingErrorCodes.MISSING_PARAMETER,"String_Node_Str");
GeocodingResult[] gresults=geocoder.geocode(req.getQuery(),req.getLanguage(),req.getBoundary(),req.getLimit());
writeGeocodingResponse(response,req,gresults);
}
}
 catch (Exception ex) {
throw new InternalServerException(GeocodingErrorCodes.UKNOWN);
}
}