代码改变世界

[hyddd的FindBugs分析记录][M V EI] May expose internal representation by returning reference to mutable object

2009-02-16 09:15  hyddd  阅读(7160)  评论(0编辑  收藏  举报

[M V EI] May expose internal representation by returning reference to mutable object [EI_EXPOSE_REP]

Returning a reference to a mutable object value stored in one of the object's fields exposes the internal representation of the object.  If instances are accessed by untrusted code, and unchecked changes to the mutable object would compromise security or other important properties, you will need to do something different. Returning a new copy of the object is better approach in many situations.

 

这个问题的解决方案和[M V EI2] May expose internal representation by incorporating reference to mutable object很类似,可以参考:http://www.cnblogs.com/hyddd/articles/1391118.html