sonatype/nexus — pull request #44 by mcculls (2011-11-04 20:31:52+00:00)
Title: **EXPERIMENTAL PATCH** support lock downgrading

At the moment once a resource lock is upgraded from shared to exclusive mode in Nexus, it will remain locked in exclusive mode until the very last unlock call. It would be more intuitive (and could help performance) if the resource lock was instead downgraded from exclusive to shared mode by the unlock call that corresponds to the original call that upgraded the lock:

```
try
{
resource.lockShared();
//
// ...etc...
//
try
{
resource.lockExclusive(); // upgrade
//
// ...etc...
//
}
finally
{
resource.unlock(); // downgrade
}
}
finally
{
resource.unlock();
}
```

This patch updates both the SimpleResource and SisuResource implementations to use the new semantics.

This patch requires careful code review and rigorous testing. Some pieces of code will now be running under a (downgraded) shared lock, and they might have been written expecting that the exclusive lock would be maintained until the very last unlock.