Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

When the backing list is inaccessible to an untrusted client, note that this advice is consistent with guideline rule LCK04-J. Do not synchronize on a collection view if the backing collection is accessible.

...

If the Book class changes its synchronization policy in the future, the BookWrapper class's locking strategy might silently break. For instance, the Bookwrapper class's locking strategy breaks if Book is modified to use a private final lock object, as recommended by guideline rule LCK00-J. Use private final lock objects to synchronize classes that may interact with untrusted code. The BookWrapper class's locking strategy breaks because threads that call BookWrapper.getDueDate() may perform operations on the thread-safe Book using its new locking policy. However, threads that call the renew() method will always synchronize on the intrinsic lock of the Book instance. Consequently, the implementation will use two different locks.

...

Wiki Markup
If the {{IPAddressList}} class is modified to use block synchronization on a private final lock object, as recommended by guidelinerule [LCK00-J. Use private final lock objects to synchronize classes that may interact with untrusted code], the {{PrintableIPAddressList}} subclass will silently break. Moreover, if a wrapper such as {{Collections.synchronizedList()}} is used, it is difficult for a client to determine the type of the class being wrapped to extend it \[[Goetz 2006|AA. Bibliography#Goetz 06]\].

...

Composition offers encapsulation benefits, usually with minimal overhead. Refer to guideline rule OBJ07-J. Preserve dependencies in subclasses when changing superclasses for more information on composition.

...

Search for vulnerabilities resulting from the violation of this guideline rule on the CERT website.

Bibliography

...