use of com.google.api.services.clouddebugger.v2.model.SetBreakpointResponse in project google-cloud-intellij by GoogleCloudPlatform.
the class CloudDebugProcessStateController method setBreakpointAsync.
/**
* Called from the {@link CloudDebugProcessHandler} to set a breakpoint.
*/
@SuppressWarnings("FutureReturnValueIgnored")
void setBreakpointAsync(@NotNull final Breakpoint serverBreakpoint, @NotNull final SetBreakpointHandler handler) {
if (state == null) {
handler.onError(GctBundle.getString("clouddebug.invalid.state"));
return;
}
final Debugger client = CloudDebuggerClient.getLongTimeoutClient(state);
if (client == null) {
LOG.warn("no client available attempting to setBreakpoint");
handler.onError(GctBundle.getString("clouddebug.bad.login.message"));
return;
}
final String debuggeeId = state.getDebuggeeId();
assert debuggeeId != null;
ApplicationManager.getApplication().executeOnPooledThread(() -> {
try {
// Delete old breakpoints at this location.
List<Breakpoint> currentList = state.getCurrentServerBreakpointList();
SourceLocation location = serverBreakpoint.getLocation();
for (Breakpoint serverBp : currentList) {
if (!Boolean.TRUE.equals(serverBp.getIsFinalState()) && serverBp.getLocation().getLine() != null && serverBp.getLocation().getLine().equals(location.getLine()) && !Strings.isNullOrEmpty(serverBp.getLocation().getPath()) && serverBp.getLocation().getPath().equals(location.getPath())) {
// should not be async here.
deleteBreakpoint(serverBp.getId());
}
}
SetBreakpointResponse addResponse = client.debuggees().breakpoints().set(debuggeeId, serverBreakpoint).setClientVersion(ServiceManager.getService(PluginInfoService.class).getClientVersionForCloudDebugger()).execute();
if (addResponse != null && addResponse.getBreakpoint() != null) {
Breakpoint result = addResponse.getBreakpoint();
if (result.getStatus() != null && Boolean.TRUE.equals(result.getStatus().getIsError()) && result.getStatus().getDescription() != null) {
handler.onError(BreakpointUtil.getUserErrorMessage(result.getStatus()));
}
handler.onSuccess(addResponse.getBreakpoint().getId());
} else {
handler.onError(GctBundle.getString("clouddebug.no.response"));
}
} catch (IOException ex) {
LOG.error("exception setting a breakpoint", ex);
handler.onError(ex.toString());
}
});
}
Aggregations