无法在try/catch block
中包装流对象。Java:捕捉lambda异常
我想是这样的:
reponseNodes.stream().parallel().collect(Collectors.toMap(responseNode -> responseNode.getLabel(), responseNode -> processImage(responseNode)));
启动Eclipse抱怨强调processImage(responseNode)
和建议,它需要Surround with try/catch
。
然后我更新为:
return reponseNodes.stream().parallel().collect(Collectors.toMap(responseNode -> responseNode.getLabel(), responseNode -> try { processImage(responseNode) } catch (Exception e) { throw new UncheckedException(e); }));
更新代码也没有工作。
您可以输入Eclipse提供给您的确切警告/错误吗? –
Eclipse警告'环绕着try/catch'强调'processImage(responseNode)'。 –