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

Reviewed-by: asaha
This commit is contained in:
Sunita Koppar 2010-10-07 00:51:42 -07:00
parent 7720bcf09c
commit d22fa91e86

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -32,6 +32,7 @@ import java.nio.channels.SelectionKey;
import java.nio.channels.Selector; import java.nio.channels.Selector;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
@ -66,7 +67,7 @@ public class SelectorImpl
private List deferredRegistrations; private List deferredRegistrations;
private List interestOpsList; private List interestOpsList;
private HashMap listenerThreads; private HashMap listenerThreads;
private HashMap readerThreads; private Map readerThreads;
private boolean selectorStarted; private boolean selectorStarted;
private boolean closed; private boolean closed;
private ORBUtilSystemException wrapper ; private ORBUtilSystemException wrapper ;
@ -81,7 +82,7 @@ public class SelectorImpl
deferredRegistrations = new ArrayList(); deferredRegistrations = new ArrayList();
interestOpsList = new ArrayList(); interestOpsList = new ArrayList();
listenerThreads = new HashMap(); listenerThreads = new HashMap();
readerThreads = new HashMap(); readerThreads = java.util.Collections.synchronizedMap(new HashMap());
closed = false; closed = false;
wrapper = ORBUtilSystemException.get(orb,CORBALogDomains.RPC_TRANSPORT); wrapper = ORBUtilSystemException.get(orb,CORBALogDomains.RPC_TRANSPORT);
} }
@ -178,8 +179,13 @@ public class SelectorImpl
} }
if (eventHandler.shouldUseSelectThreadToWait()) { if (eventHandler.shouldUseSelectThreadToWait()) {
SelectionKey selectionKey = eventHandler.getSelectionKey(); SelectionKey selectionKey ;
selectionKey.cancel(); synchronized(deferredRegistrations) {
selectionKey = eventHandler.getSelectionKey();
}
if (selectionKey != null) {
selectionKey.cancel();
}
selector.wakeup(); selector.wakeup();
return; return;
} }