org.sonar.l10n.java.rules.java.S2675.html Maven / Gradle / Ivy
Why is this an issue?
The readObject
method is implemented when a Serializable
object requires special handling to be reconstructed from a
file. The object created by readObject
is accessed only by the thread that called the method, thus using the synchronized
keyword in this context is unnecessary and causes confusion.
Noncompliant code example
private synchronized void readObject(java.io.ObjectInputStream in)
throws IOException, ClassNotFoundException { // Noncompliant
//...
}
Compliant solution
private void readObject(java.io.ObjectInputStream in)
throws IOException, ClassNotFoundException { // Compliant
//...
}
Resources
Documentation
Articles & blog posts
© 2015 - 2024 Weber Informatics LLC | Privacy Policy