summaryrefslogtreecommitdiff
path: root/qpid/java/common
diff options
context:
space:
mode:
authorAndrew Donald Kennedy <grkvlt@apache.org>2010-08-13 13:54:03 +0000
committerAndrew Donald Kennedy <grkvlt@apache.org>2010-08-13 13:54:03 +0000
commit85c161b9da988745cceeae3be3c082d02062b5b3 (patch)
treea88297935c4a88b79e682877dc183099b8ffb8df /qpid/java/common
parent58c7fd662a4d37ff3b387575e0c0d3b80e7e7368 (diff)
downloadqpid-python-85c161b9da988745cceeae3be3c082d02062b5b3.tar.gz
QPID-2797: Change expiry to a boolean correctly representing intent to close
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@985199 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/common')
-rw-r--r--qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionDelegate.java2
-rw-r--r--qpid/java/common/src/main/java/org/apache/qpid/transport/Session.java30
-rw-r--r--qpid/java/common/src/main/java/org/apache/qpid/transport/SessionDelegate.java5
3 files changed, 22 insertions, 15 deletions
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionDelegate.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionDelegate.java
index 9ef7a47e1b..29389df99a 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionDelegate.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionDelegate.java
@@ -85,8 +85,8 @@ public abstract class ConnectionDelegate
@Override public void sessionDetach(Connection conn, SessionDetach dtc)
{
Session ssn = conn.getSession(dtc.getChannel());
- conn.unmap(ssn);
ssn.sessionDetached(dtc.getName(), SessionDetachCode.NORMAL);
+ conn.unmap(ssn);
ssn.closed();
}
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/Session.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/Session.java
index 40df4e4bc8..5e40527c2f 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/Session.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/Session.java
@@ -85,6 +85,7 @@ public class Session extends SessionInvoker
private Connection connection;
private Binary name;
private long expiry;
+ private boolean closing;
private int channel;
private SessionDelegate delegate;
private SessionListener listener = new DefaultSessionListener();
@@ -127,6 +128,7 @@ public class Session extends SessionInvoker
this.delegate = delegate;
this.name = name;
this.expiry = expiry;
+ this.closing = false;
initReceiver();
}
@@ -145,6 +147,11 @@ public class Session extends SessionInvoker
this.expiry = expiry;
}
+ void setClose(boolean close)
+ {
+ this.closing = close;
+ }
+
public int getChannel()
{
return channel;
@@ -599,7 +606,7 @@ public class Session extends SessionInvoker
}
catch (SenderException e)
{
- if (expiry > 0)
+ if (!closing)
{
// if expiry is > 0 then this will
// happen again on resume
@@ -637,7 +644,7 @@ public class Session extends SessionInvoker
{
sessionCommandPoint(0, 0);
}
- if ((expiry > 0 && !m.isUnreliable()) || m.hasCompletionListener())
+ if ((!closing && !m.isUnreliable()) || m.hasCompletionListener())
{
commands[mod(next, commands.length)] = m;
commandBytes += m.getBodySize();
@@ -654,9 +661,9 @@ public class Session extends SessionInvoker
}
catch (SenderException e)
{
- if (expiry > 0)
+ if (!closing)
{
- // if expiry is > 0 then this will happen
+ // if we are not closing then this will happen
// again on resume
log.error(e, "error sending command");
}
@@ -680,7 +687,7 @@ public class Session extends SessionInvoker
}
catch (SenderException e)
{
- if (expiry > 0)
+ if (!closing)
{
// if expiry is > 0 then this will happen
// again on resume
@@ -890,13 +897,10 @@ public class Session extends SessionInvoker
synchronized (commands)
{
state = CLOSING;
- // XXX: we manually set the expiry to zero here to
- // simulate full session recovery in brokers that don't
- // support it, we should remove this line when there is
- // broker support for full session resume:
- expiry = 0;
+ setClose(true);
sessionRequestTimeout(0);
sessionDetach(name.getBytes());
+
Waiter w = new Waiter(commands, timeout);
while (w.hasTime() && state != CLOSED)
{
@@ -907,9 +911,9 @@ public class Session extends SessionInvoker
{
throw new SessionException("close() timed out");
}
+
+ connection.removeSession(this);
}
-
- connection.removeSession(this);
}
public void exception(Throwable t)
@@ -921,7 +925,7 @@ public class Session extends SessionInvoker
{
synchronized (commands)
{
- if (expiry == 0 || getException() != null)
+ if (closing || getException() != null)
{
state = CLOSED;
}
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionDelegate.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionDelegate.java
index b9077e98ab..79087d83a8 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionDelegate.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionDelegate.java
@@ -59,7 +59,10 @@ public class SessionDelegate
@Override public void sessionRequestTimeout(Session ssn, SessionRequestTimeout t)
{
- ssn.setExpiry(t.getTimeout());
+ if (t.getTimeout() == 0)
+ {
+ ssn.setClose(true);
+ }
ssn.sessionTimeout(t.getTimeout());
}