Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2012-09-21 04:16:27 +0000
committerEike Stepper2012-09-21 04:16:27 +0000
commit9074986c528363ed495d12e15788e90becad3316 (patch)
tree20b48634bd3f11588c42d6d9dacf631ec6c82497
parentad96ed4c75620ce6cbd9b3eab0b7a60de65ae9e4 (diff)
downloadcdo-9074986c528363ed495d12e15788e90becad3316.tar.gz
cdo-9074986c528363ed495d12e15788e90becad3316.tar.xz
cdo-9074986c528363ed495d12e15788e90becad3316.zip
[389525] Concurrent Access to Models Rollback / Conflict Resolution
Exceptions https://bugs.eclipse.org/bugs/show_bug.cgi?id=389525
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOViewImpl.java2
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/buffer/BufferInputStream.java78
2 files changed, 41 insertions, 39 deletions
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOViewImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOViewImpl.java
index 42cbcfb261..ba1dee2eea 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOViewImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOViewImpl.java
@@ -408,7 +408,7 @@ public class CDOViewImpl extends AbstractCDOView
try
{
- synchronized (this)
+ synchronized (lockStates)
{
if (!options().isLockNotificationEnabled())
{
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/buffer/BufferInputStream.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/buffer/BufferInputStream.java
index 61e81f7c9a..146d4567d7 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/buffer/BufferInputStream.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/buffer/BufferInputStream.java
@@ -29,7 +29,7 @@ import java.util.concurrent.TimeUnit;
/**
* A {@link IBufferHandler buffer handler} that defragments the passed {@link IBuffer buffers} into a continuous byte
* sequence which is exposed as an {@link InputStream input stream}.
- *
+ *
* @author Eike Stepper
*/
public class BufferInputStream extends InputStream implements IBufferHandler
@@ -163,49 +163,33 @@ public class BufferInputStream extends InputStream implements IBufferHandler
try
{
- if (getMillisBeforeTimeout() == NO_TIMEOUT)
+ boolean noTimeout = getMillisBeforeTimeout() == NO_TIMEOUT;
+ if (!noTimeout)
{
- while (currentBuffer == null)
- {
- throwRemoteExceptionIfExists();
+ restartTimeout();
+ }
+
+ while (currentBuffer == null)
+ {
+ throwRemoteExceptionIfExists();
- if (buffers == null)
- {
- // Stream has been closed - shutting down
- return false;
- }
+ if (buffers == null)
+ {
+ // Stream has been closed - shutting down
+ return false;
+ }
- currentBuffer = buffers.poll(check, TimeUnit.MILLISECONDS);
+ long timeout;
+ if (noTimeout)
+ {
+ timeout = check;
}
- }
- else
- {
- restartTimeout();
- while (currentBuffer == null)
+ else
{
- throwRemoteExceptionIfExists();
-
- if (buffers == null)
- {
- // Stream has been closed - shutting down
- return false;
- }
-
- long remaining;
- synchronized (this)
- {
- remaining = stopTimeMillis;
- }
-
- remaining -= System.currentTimeMillis();
- if (remaining <= 0)
- {
- // Throw an exception so that caller can distinguish between end-of-stream and a timeout
- throw new IOTimeoutException();
- }
-
- currentBuffer = buffers.poll(Math.min(remaining, check), TimeUnit.MILLISECONDS);
+ timeout = computeTimeout(check);
}
+
+ currentBuffer = buffers.poll(timeout, TimeUnit.MILLISECONDS);
}
}
catch (InterruptedException ex)
@@ -217,6 +201,24 @@ public class BufferInputStream extends InputStream implements IBufferHandler
return true;
}
+ private long computeTimeout(final long check) throws IOTimeoutException
+ {
+ long remaining;
+ synchronized (this)
+ {
+ remaining = stopTimeMillis;
+ }
+
+ remaining -= System.currentTimeMillis();
+ if (remaining <= 0)
+ {
+ // Throw an exception so that caller can distinguish between end-of-stream and a timeout
+ throw new IOTimeoutException();
+ }
+
+ return Math.min(remaining, check);
+ }
+
private void throwRemoteExceptionIfExists()
{
if (exception != null)

Back to the top