You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by ff...@apache.org on 2016/11/22 08:13:55 UTC
cxf git commit: [CXF-7145]synchronized store and getMessages of
JmsPullPoint would cause deadlock
Repository: cxf
Updated Branches:
refs/heads/master 040a1d9ef -> e47a79f94
[CXF-7145]synchronized store and getMessages of JmsPullPoint would cause deadlock
(cherry picked from commit 574090d1180ae3718ffe1ab9dbbb6f49ad67b5a2)
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/e47a79f9
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/e47a79f9
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/e47a79f9
Branch: refs/heads/master
Commit: e47a79f94adb804a8d0e498fd47bed4388ff0797
Parents: 040a1d9
Author: Freeman Fang <fr...@gmail.com>
Authored: Tue Nov 22 16:10:36 2016 +0800
Committer: Freeman Fang <fr...@gmail.com>
Committed: Tue Nov 22 16:12:59 2016 +0800
----------------------------------------------------------------------
.../org/apache/cxf/wsn/jms/JmsPullPoint.java | 39 +++++++++-----------
1 file changed, 18 insertions(+), 21 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf/blob/e47a79f9/services/wsn/wsn-core/src/main/java/org/apache/cxf/wsn/jms/JmsPullPoint.java
----------------------------------------------------------------------
diff --git a/services/wsn/wsn-core/src/main/java/org/apache/cxf/wsn/jms/JmsPullPoint.java b/services/wsn/wsn-core/src/main/java/org/apache/cxf/wsn/jms/JmsPullPoint.java
index 92d50ae..b56fe92 100644
--- a/services/wsn/wsn-core/src/main/java/org/apache/cxf/wsn/jms/JmsPullPoint.java
+++ b/services/wsn/wsn-core/src/main/java/org/apache/cxf/wsn/jms/JmsPullPoint.java
@@ -72,7 +72,7 @@ public class JmsPullPoint extends AbstractPullPoint {
}
}
- protected void initSession() throws JMSException {
+ protected synchronized void initSession() throws JMSException {
if (session == null) {
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
queue = session.createQueue(getName());
@@ -80,9 +80,21 @@ public class JmsPullPoint extends AbstractPullPoint {
consumer = session.createConsumer(queue);
}
}
+
+ protected synchronized void closeSession() {
+ if (session != null) {
+ try {
+ session.close();
+ } catch (JMSException inner) {
+ LOGGER.log(Level.FINE, "Error closing session", inner);
+ } finally {
+ session = null;
+ }
+ }
+ }
@Override
- protected synchronized void store(NotificationMessageHolderType messageHolder) {
+ protected void store(NotificationMessageHolderType messageHolder) {
try {
initSession();
Notify notify = new Notify();
@@ -93,22 +105,15 @@ public class JmsPullPoint extends AbstractPullPoint {
producer.send(message);
} catch (JMSException e) {
LOGGER.log(Level.WARNING, "Error storing message", e);
- if (session != null) {
- try {
- session.close();
- } catch (JMSException inner) {
- LOGGER.log(Level.FINE, "Error closing session", inner);
- } finally {
- session = null;
- }
- }
+ closeSession();
+
} catch (JAXBException e) {
LOGGER.log(Level.WARNING, "Error storing message", e);
}
}
@Override
- protected synchronized List<NotificationMessageHolderType> getMessages(int max)
+ protected List<NotificationMessageHolderType> getMessages(int max)
throws ResourceUnknownFault, UnableToGetMessagesFault {
try {
if (max == 0) {
@@ -135,15 +140,7 @@ public class JmsPullPoint extends AbstractPullPoint {
return messages;
} catch (JMSException e) {
LOGGER.log(Level.INFO, "Error retrieving messages", e);
- if (session != null) {
- try {
- session.close();
- } catch (JMSException inner) {
- LOGGER.log(Level.FINE, "Error closing session", inner);
- } finally {
- session = null;
- }
- }
+ closeSession();
UnableToGetMessagesFaultType fault = new UnableToGetMessagesFaultType();
throw new UnableToGetMessagesFault("Unable to retrieve messages", fault, e);
} catch (JAXBException e) {