public List<OpBase> getHistory(ESRequest historyRequest)
throws IOException, ResourceNotFoundException, URISyntaxException {
String url = baseUrl + opIndex + "/_search";
String resp = makeESQuery(historyRequest, url);
HistoryResponse historyResponse = objectMapper.readValue(resp, HistoryResponse.class);
List<OpBase> returnMsgList = new ArrayList<>();
historyResponse.tasks.tasks.forEach(editTaskMsgResponse -> {
Map<String, Object> msgObject = editTaskMsgResponse.source.msg;
String taskType = (String) msgObject.get("task_type");
EditTaskType editTaskType = EditTaskType.valueOf(taskType);
switch(editTaskType) {
case MIGRATE_PLACE: returnMsgList.add(objectMapper.readValue(
objectMapper.writeValueAsString(msgObject), MatchingTaskOperatorMetricsMsg.class));
case CURATE_PLACE:
case QC_PLACE: returnMsgList.add(objectMapper.readValue(objectMapper.writeValueAsString(msgObject),
MatchingTaskOperatorMetricsMsg.class));
}
});
return returnMsgList;
}
我使用objectMapper.readValue(objectMapper.writeValueAsString(msgObject),
MatchingTaskOperatorMetricsMsg.class));
但是我明确地说这个方法会抛出这个异常吗?
答案 0 :(得分:2)
此警告可能会显示包含在 private void Grid_Loaded_1(object sender, RoutedEventArgs e)
{
Grid grd = sender as Grid;
DependencyObject parent = grd;
while (!((parent = VisualTreeHelper.GetParent(parent)) is Window)) ;
if (parent == null) return;
grd.Width = (parent as Window).ActualWidth / 2;
}
语句中的行。在它之外的那个工作正常。
原因是因为该代码位于switch-case
表达式中。未处理的异常不会以这种方式在stream和lambda表达式中处理。
您必须将lambda
表达式中编写的代码包装在lambda
try-catch
另见: