1320
Instead, in a correct usage, the synchronized statement should contain procedures that access or
modify data that is exposed to multiple threads. For example, consider a scenario in which several
threads are accessing student records at the same time. The method which sets the student ID to a
new value will need to make sure that nobody else is accessing this data at the same time and will
require synchronization.
Example Language: (Good)
public void setID(int ID){
synchronized(this){
this.ID = ID;
}
}
MemberOf Relationships
This MemberOf relationships table shows additional CWE Catgeories and Views that reference this
weakness as a member. This information is often useful in understanding where a weakness fits
within the context of external information sources.
Nature Type ID Name Page
MemberOf 987 SFP Secondary Cluster: Multiple Locks/Unlocks 888 2412
MemberOf 1412 Comprehensive Categorization: Poor Coding Practices 1400 2538
Taxonomy Mappings
Mapped Taxonomy Name Node ID Fit Mapped Node Name
Software Fault Patterns SFP21 Multiple locks/unlocks
References
[REF-478]"Intrinsic Locks and Synchronization (in Java)". < https://docs.oracle.com/javase/tutorial/
essential/concurrency/locksync.html >.2023-04-07.
CWE-586: Explicit Call to Finalize()
Weakness ID : 586
Structure : Simple
Abstraction : Base
Description
The product makes an explicit call to the finalize() method from outside the finalizer.
Extended Description
While the Java Language Specification allows an object's finalize() method to be called from
outside the finalizer, doing so is usually a bad idea. For example, calling finalize() explicitly means
that finalize() will be called more than once: the first time will be the explicit call and the last time
will be the call that is made after the object is garbage collected.
Relationships
The table(s) below shows the weaknesses and high level categories that are related to this
weakness. These relationships are defined as ChildOf, ParentOf, MemberOr and give insight to
similar items that may exist at higher and lower levels of abstraction. In addition, relationships such
as PeerOf and CanAlsoBe are defined to show similar weaknesses that may want to be explored.
Relevant to the view "Research Concepts" (CWE-1000)
Nature Type ID Name Page
ChildOf 1076 Insufficient Adherence to Expected Conventions 1916
CWE Version 4.14
CWE-586: Explicit Call to Finalize()
CWE-586: Explicit Call to Finalize()