7046238: new InitialContext(); hangs
Synchronization on a single monitor for contactInfo parameters with identical hashCode() Reviewed-by: robm, skoppar
This commit is contained in:
parent
b6bd9844c4
commit
2829f07b30
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2001, 2011, 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
|
||||||
@ -113,6 +113,9 @@ import com.sun.corba.se.impl.protocol.giopmsgheaders.ReferenceAddr;
|
|||||||
import com.sun.corba.se.impl.transport.CorbaContactInfoListIteratorImpl;
|
import com.sun.corba.se.impl.transport.CorbaContactInfoListIteratorImpl;
|
||||||
import com.sun.corba.se.impl.util.JDKBridge;
|
import com.sun.corba.se.impl.util.JDKBridge;
|
||||||
|
|
||||||
|
import java.util.concurrent.ConcurrentMap;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ClientDelegate is the RMI client-side subcontract or representation
|
* ClientDelegate is the RMI client-side subcontract or representation
|
||||||
* It implements RMI delegate as well as our internal ClientRequestDispatcher
|
* It implements RMI delegate as well as our internal ClientRequestDispatcher
|
||||||
@ -122,6 +125,9 @@ public class CorbaClientRequestDispatcherImpl
|
|||||||
implements
|
implements
|
||||||
ClientRequestDispatcher
|
ClientRequestDispatcher
|
||||||
{
|
{
|
||||||
|
private ConcurrentMap<ContactInfo, Object> locks =
|
||||||
|
new ConcurrentHashMap<ContactInfo, Object>();
|
||||||
|
|
||||||
public OutputObject beginRequest(Object self, String opName,
|
public OutputObject beginRequest(Object self, String opName,
|
||||||
boolean isOneWay, ContactInfo contactInfo)
|
boolean isOneWay, ContactInfo contactInfo)
|
||||||
{
|
{
|
||||||
@ -148,8 +154,21 @@ public class CorbaClientRequestDispatcherImpl
|
|||||||
|
|
||||||
// This locking is done so that multiple connections are not created
|
// This locking is done so that multiple connections are not created
|
||||||
// for the same endpoint
|
// for the same endpoint
|
||||||
//6929137 - Synchronized on contactInfo to avoid blocking across multiple endpoints
|
// 7046238 - Synchronization on a single monitor for contactInfo parameters
|
||||||
synchronized (contactInfo) {
|
// with identical hashCode(), so we lock on same monitor for equal parameters
|
||||||
|
// (which can refer to equal (in terms of equals()) but not the same objects)
|
||||||
|
|
||||||
|
Object lock = locks.get(contactInfo);
|
||||||
|
|
||||||
|
if (lock == null) {
|
||||||
|
Object newLock = new Object();
|
||||||
|
lock = locks.putIfAbsent(contactInfo, newLock);
|
||||||
|
if (lock == null) {
|
||||||
|
lock = newLock;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
synchronized (lock) {
|
||||||
if (contactInfo.isConnectionBased()) {
|
if (contactInfo.isConnectionBased()) {
|
||||||
if (contactInfo.shouldCacheConnection()) {
|
if (contactInfo.shouldCacheConnection()) {
|
||||||
connection = (CorbaConnection)
|
connection = (CorbaConnection)
|
||||||
@ -254,7 +273,7 @@ public class CorbaClientRequestDispatcherImpl
|
|||||||
registerWaiter(messageMediator);
|
registerWaiter(messageMediator);
|
||||||
|
|
||||||
// Do connection reclaim now
|
// Do connection reclaim now
|
||||||
synchronized (contactInfo) {
|
synchronized (lock) {
|
||||||
if (contactInfo.isConnectionBased()) {
|
if (contactInfo.isConnectionBased()) {
|
||||||
if (contactInfo.shouldCacheConnection()) {
|
if (contactInfo.shouldCacheConnection()) {
|
||||||
OutboundConnectionCache connectionCache =
|
OutboundConnectionCache connectionCache =
|
||||||
|
Loading…
x
Reference in New Issue
Block a user