I am a little confused as to why my Spring service is not returning any content. I tried mvn clean install
and I also see that the response POJO at the return statement line has actual data when I hit the breakpoint in debugger mode/print to console. Does anyone know what could be the cause?
My @RestController
@Override
public MyServiceResponse getDesiredData(MyRequest myRequest)
throws IOException {
var resp = new MyServiceResponse();
var req = new ServiceRequest<MyRequest>();
req.setPayload(myRequest);
// this update the pass by reference resp object
myRequestProcessor.process(req, resp);
return resp; //at this breakpoint I see data in the debugging console
}
POJO:
@SuperBuilder
@Data
@NoArgsConstructor
@JsonIgnoreProperties(ignoreUnknown = true)
public class MyServiceResponse {
SessionInfo sessionInfo;
}
@SuperBuilder
@Data
@NoArgsConstructor
@JsonIgnoreProperties(ignoreUnknown = true)
public class SessionInfo {
Parameters parameters;
}
@SuperBuilder
@Data
@NoArgsConstructor
@JsonIgnoreProperties(ignoreUnknown = true)
public class Parameters {
@JsonProperty("zip")
String zip;
@JsonProperty("city")
String city;
@JsonProperty("state")
String state;
@JsonProperty("storeNum")
Integer storeNum;
@JsonProperty("startHrs")
String startHrs;
@JsonProperty("endHrs")
String endHrs;
}
2
Answers
It turns out that in my specific case there is another class in the service package that implements the following:
Due to this, the processorLogging is called before and after the API method is called in ControllerImpl. Inside this method the logic did not support a new POJO as the response object so I needed to add that support.