Commit c998909e authored by Robin Collier's avatar Robin Collier Committed by rcollier

OF-205 Put synchronization in place on realization of transient members.

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@13308 b35dd754-fafc-0310-a699-88a17e54d16e
parent 2c8e2d71
...@@ -75,7 +75,7 @@ public class PublishedItem implements Serializable { ...@@ -75,7 +75,7 @@ public class PublishedItem implements Serializable {
/** /**
* The node where the item was published. * The node where the item was published.
*/ */
private transient LeafNode node; private volatile transient LeafNode node;
/** /**
* The id for the node where the item was published. * The id for the node where the item was published.
*/ */
...@@ -96,7 +96,7 @@ public class PublishedItem implements Serializable { ...@@ -96,7 +96,7 @@ public class PublishedItem implements Serializable {
* The optional payload is included when publishing the item. This value * The optional payload is included when publishing the item. This value
* is created from the payload XML and cached as/when needed. * is created from the payload XML and cached as/when needed.
*/ */
private transient Element payload; private volatile transient Element payload;
/** /**
* XML representation of the payload (for serialization) * XML representation of the payload (for serialization)
*/ */
...@@ -127,13 +127,20 @@ public class PublishedItem implements Serializable { ...@@ -127,13 +127,20 @@ public class PublishedItem implements Serializable {
*/ */
public LeafNode getNode() { public LeafNode getNode() {
if (node == null) { if (node == null) {
if (Node.PUBSUB_SVC_ID.equals(serviceId)) { synchronized (this) {
node = (LeafNode) XMPPServer.getInstance().getPubSubModule().getNode(nodeId); if (node == null) {
} else { if (Node.PUBSUB_SVC_ID.equals(serviceId))
PEPServiceManager serviceMgr = XMPPServer.getInstance().getIQPEPHandler().getServiceManager(); {
node = serviceMgr.hasCachedService(new JID(serviceId)) ? node = (LeafNode) XMPPServer.getInstance().getPubSubModule().getNode(nodeId);
(LeafNode) serviceMgr.getPEPService(serviceId).getNode(nodeId) : null; }
} else
{
PEPServiceManager serviceMgr = XMPPServer.getInstance().getIQPEPHandler().getServiceManager();
node = serviceMgr.hasCachedService(new JID(serviceId)) ? (LeafNode) serviceMgr.getPEPService(
serviceId).getNode(nodeId) : null;
}
}
}
} }
return node; return node;
} }
...@@ -174,18 +181,22 @@ public class PublishedItem implements Serializable { ...@@ -174,18 +181,22 @@ public class PublishedItem implements Serializable {
*/ */
public Element getPayload() { public Element getPayload() {
if (payload == null && payloadXML != null) { if (payload == null && payloadXML != null) {
// payload initialized as XML string from DB synchronized (this) {
SAXReader xmlReader = null; if (payload == null) {
try { // payload initialized as XML string from DB
xmlReader = xmlReaders.take(); SAXReader xmlReader = null;
payload = xmlReader.read(new StringReader(payloadXML)).getRootElement(); try {
} catch (Exception ex) { xmlReader = xmlReaders.take();
log.error("Failed to parse payload XML", ex); payload = xmlReader.read(new StringReader(payloadXML)).getRootElement();
} finally { } catch (Exception ex) {
if (xmlReader != null) { log.error("Failed to parse payload XML", ex);
xmlReaders.add(xmlReader); } finally {
} if (xmlReader != null) {
} xmlReaders.add(xmlReader);
}
}
}
}
} }
return payload; return payload;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment