December 2013
Intermediate to advanced
256 pages
6h 56m
English
Existing explicit synchronization gives us one of the easiest seams to exploit. The most common form occurs when the code under test has a critical section that uses another class that is already thread-safe. In such cases, you can use the synchronization in the other class to suspend within the critical section. Consider the code in Listing 13-7.
Listing 13-7: An example for discussion on common lock synchronization
public final class HostInfoService { // Singleton private static HostInfoService instance; private HostInfoService() { ... } public static synchronized HostInfoService getInstance() { if (instance == null ) { instance = new HostInfoService(); } return ...
Read now
Unlock full access