Github user upthewaterspout commented on a diff in the pull request:

    https://github.com/apache/incubator-geode/pull/299#discussion_r90077848
  
    --- Diff: 
geode-core/src/main/java/org/apache/geode/internal/statistics/StatMonitorHandler.java
 ---
    @@ -50,36 +50,26 @@ public StatMonitorHandler() {
     
       /** Adds a monitor which will be notified of samples */
       public boolean addMonitor(StatisticsMonitor monitor) {
    -    synchronized (this) {
    -      boolean added = false;
    -      List<StatisticsMonitor> oldMonitors = this.monitors;
    -      if (!oldMonitors.contains(monitor)) {
    -        List<StatisticsMonitor> newMonitors = new 
ArrayList<StatisticsMonitor>(oldMonitors);
    -        added = newMonitors.add(monitor);
    -        this.monitors = Collections.unmodifiableList(newMonitors);
    -      }
    -      if (!this.monitors.isEmpty()) {
    -        startNotifier_IfEnabledAndNotRunning();
    -      }
    -      return added;
    +    boolean added = false;
    +    if (!this.monitors.contains(monitor)) {
    +      added = this.monitors.add(monitor);
    +    }
    +    if (!this.monitors.isEmpty()) {
    +      startNotifier_IfEnabledAndNotRunning();
         }
    +    return added;
       }
     
       /** Removes a monitor that will no longer be used */
       public boolean removeMonitor(StatisticsMonitor monitor) {
    -    synchronized (this) {
    -      boolean removed = false;
    -      List<StatisticsMonitor> oldMonitors = this.monitors;
    -      if (oldMonitors.contains(monitor)) {
    -        List<StatisticsMonitor> newMonitors = new 
ArrayList<StatisticsMonitor>(oldMonitors);
    -        removed = newMonitors.remove(monitor);
    -        this.monitors = Collections.unmodifiableList(newMonitors);
    -      }
    -      if (this.monitors.isEmpty()) {
    -        stopNotifier_IfEnabledAndRunning();
    -      }
    -      return removed;
    +    boolean removed = false;
    --- End diff --
    
    Same issue here - it's not safe to remove the synchronization.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to