美文网首页
浅析unsupportedoperationexception

浅析unsupportedoperationexception

作者: SaMichael | 来源:发表于2016-01-08 11:32 被阅读77次

在测试环境开发时遇到个奇怪的问题,一直抛unsupportedoperationexception

debug看到map在put时抛出该异常

一般抛这种异常,都是因为集合是final的,比如Arrays.asList()就不能做加减操作

查找上游代码,发现try catch异常,在catch异常时返回Collections.emptyMap()。返回的map是final的,下游代码并不清楚导致

相关文章

网友评论

      本文标题:浅析unsupportedoperationexception

      本文链接:https://www.haomeiwen.com/subject/vtmfkttx.html