Bug 49685 - Unsafe synchronization in class ManagedBean
Summary: Unsafe synchronization in class ManagedBean
Status: RESOLVED WONTFIX
Alias: None
Product: Tomcat Modules
Classification: Unclassified
Component: Tomcat Lite (show other bugs)
Version: unspecified
Hardware: PC Windows XP
: P2 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-02 01:42 UTC by Wendy
Modified: 2016-11-21 11:27 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Wendy 2010-08-02 01:42:27 UTC
Class ManagedBean has eneffectiv code as follow:
 
public void addNotification(NotificationInfo notification) {

        synchronized (notifications) {
            NotificationInfo results[] =
                new NotificationInfo[notifications.length + 1];
            System.arraycopy(notifications, 0, results, 0,
                             notifications.length);
            results[notifications.length] = notification;
            notifications = results;
            this.info = null;
        }

    }

In this case, the object of notifications has been changed in the synchronized block. this may cause two threads synchronizing on different objects. If thread A and B access this method concurrently, and thread A execute the code  " notifications = results; " earlier and then finished while thread B is still not finished. At the same time, Thread C access this method, then C will hold the different lock instance as Thread B. This is dangerous.
Comment 1 Mark Thomas 2016-11-21 11:27:05 UTC
Tomcat-lite is no longer being developed