6896157: unsynchronized hashmap in com.sun.corba.se.impl.transport.SelectorImpl.createReaderThread

Thu, 07 Oct 2010 00:51:42 -0700

author
skoppar
date
Thu, 07 Oct 2010 00:51:42 -0700
changeset 228
2d3622317730
parent 227
459c07278c3c
child 229
5f026ab0098c

6896157: unsynchronized hashmap in com.sun.corba.se.impl.transport.SelectorImpl.createReaderThread
Reviewed-by: asaha

src/share/classes/com/sun/corba/se/impl/transport/SelectorImpl.java file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/classes/com/sun/corba/se/impl/transport/SelectorImpl.java	Thu Oct 07 00:49:05 2010 -0700
     1.2 +++ b/src/share/classes/com/sun/corba/se/impl/transport/SelectorImpl.java	Thu Oct 07 00:51:42 2010 -0700
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -32,6 +32,7 @@
    1.11  import java.nio.channels.Selector;
    1.12  import java.util.ArrayList;
    1.13  import java.util.HashMap;
    1.14 +import java.util.Map;
    1.15  import java.util.Iterator;
    1.16  import java.util.List;
    1.17  
    1.18 @@ -66,7 +67,7 @@
    1.19      private List deferredRegistrations;
    1.20      private List interestOpsList;
    1.21      private HashMap listenerThreads;
    1.22 -    private HashMap readerThreads;
    1.23 +    private Map readerThreads;
    1.24      private boolean selectorStarted;
    1.25      private boolean closed;
    1.26      private ORBUtilSystemException wrapper ;
    1.27 @@ -81,7 +82,7 @@
    1.28          deferredRegistrations = new ArrayList();
    1.29          interestOpsList = new ArrayList();
    1.30          listenerThreads = new HashMap();
    1.31 -        readerThreads = new HashMap();
    1.32 +        readerThreads = java.util.Collections.synchronizedMap(new HashMap());
    1.33          closed = false;
    1.34          wrapper = ORBUtilSystemException.get(orb,CORBALogDomains.RPC_TRANSPORT);
    1.35      }
    1.36 @@ -178,8 +179,13 @@
    1.37          }
    1.38  
    1.39          if (eventHandler.shouldUseSelectThreadToWait()) {
    1.40 -            SelectionKey selectionKey = eventHandler.getSelectionKey();
    1.41 -            selectionKey.cancel();
    1.42 +            SelectionKey selectionKey ;
    1.43 +            synchronized(deferredRegistrations) {
    1.44 +                selectionKey = eventHandler.getSelectionKey();
    1.45 +            }
    1.46 +            if (selectionKey != null) {
    1.47 +                selectionKey.cancel();
    1.48 +            }
    1.49              selector.wakeup();
    1.50              return;
    1.51          }

mercurial