34 lines
978 B
Plaintext
34 lines
978 B
Plaintext
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
|
|
|
|
[source,java]
|
|
----
|
|
private synchronized void readObject(java.io.ObjectInputStream in)
|
|
throws IOException, ClassNotFoundException { // Noncompliant
|
|
//...
|
|
}
|
|
----
|
|
|
|
|
|
== Compliant Solution
|
|
|
|
[source,java]
|
|
----
|
|
private void readObject(java.io.ObjectInputStream in)
|
|
throws IOException, ClassNotFoundException { // Compliant
|
|
//...
|
|
}
|
|
----
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
include::message.adoc[]
|
|
|
|
endif::env-github,rspecator-view[]
|