Chapter 13. Thread-Safety Miscellaneous (TSM)

Rules

Image

Risk Assessment Summary

Image

TSM00-J. Do not override thread-safe methods with methods that are not thread-safe

Overriding thread-safe methods with methods that are unsafe for concurrent use can result in improper synchronization when a client that depends on the thread-safety promised by the parent inadvertently operates on an instance of the subclass. For example, an overridden synchronized method’s contract can be violated when a subclass provides an implementation that is unsafe for concurrent ...

Get The CERT® Oracle® Secure Coding Standard for Java™ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.