org.sonar.l10n.java.rules.squid.S2675.html Maven / Gradle / Ivy
A readObject
method is written when a Serializable
object needs special handling to be rehydrated from file.
It should be the case that the object being created by readObject
is only visible to the thread that invoked the method,
and the synchronized
keyword is not needed, and using synchronized
anyway is just confusing.
If this is not the case, the method should be refactored to make it the case.
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
//...
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy