2

As I was returning the actual reference of Date object in a getter of a class. But SonarQube didn't accepted it a good practice. And then I found that returning references to internal mutable members of a class can compromise an application's security, both by breaking encapsulation and by providing the opportunity to corrupt the internal state of the class (whether accidentally or maliciously). Now I'm thinking: Why is java.util.Date mutable in java ?

Rob Audenaerde
  • 17,859
  • 8
  • 72
  • 114

0 Answers0