Commit 9f4bc5ad authored by guus's avatar guus

OF-607: prevent the resource-intensive JID constructor from being used when...

OF-607: prevent the resource-intensive JID constructor from being used when serializing cluster objects.

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@13425 b35dd754-fafc-0310-a699-88a17e54d16e
parent 31fefac2
......@@ -53,10 +53,10 @@ public class NotifyComponentRegistered implements ClusterTask {
}
public void writeExternal(ObjectOutput out) throws IOException {
ExternalizableUtil.getInstance().writeSafeUTF(out, componentJID.toString());
ExternalizableUtil.getInstance().writeSerializable(out, componentJID);
}
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
componentJID = new JID(ExternalizableUtil.getInstance().readSafeUTF(in));
componentJID = (JID) ExternalizableUtil.getInstance().readSerializable(in);
}
}
......@@ -55,10 +55,10 @@ public class NotifyComponentUnregistered implements ClusterTask {
}
public void writeExternal(ObjectOutput out) throws IOException {
ExternalizableUtil.getInstance().writeSafeUTF(out, componentJID.toString());
ExternalizableUtil.getInstance().writeSerializable(out, componentJID);
}
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
componentJID = new JID(ExternalizableUtil.getInstance().readSafeUTF(in));
componentJID = (JID) ExternalizableUtil.getInstance().readSerializable(in);
}
}
......@@ -96,13 +96,13 @@ public class DirectedPresence implements Externalizable {
public void writeExternal(ObjectOutput out) throws IOException {
ExternalizableUtil.getInstance().writeByteArray(out, nodeID);
ExternalizableUtil.getInstance().writeSafeUTF(out, handler.toString());
ExternalizableUtil.getInstance().writeSerializable(out, handler);
ExternalizableUtil.getInstance().writeStrings(out, receivers);
}
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
nodeID = ExternalizableUtil.getInstance().readByteArray(in);
handler = new JID(ExternalizableUtil.getInstance().readSafeUTF(in));
handler = (JID) ExternalizableUtil.getInstance().readSerializable(in);
ExternalizableUtil.getInstance().readStrings(in, receivers);
}
}
......@@ -77,14 +77,14 @@ public class AddMember extends MUCRoomTask {
@Override
public void writeExternal(ObjectOutput out) throws IOException {
super.writeExternal(out);
ExternalizableUtil.getInstance().writeSafeUTF(out, bareJID.toFullJID());
ExternalizableUtil.getInstance().writeSerializable(out, bareJID);
ExternalizableUtil.getInstance().writeSafeUTF(out, nickname);
}
@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
super.readExternal(in);
bareJID = new JID(ExternalizableUtil.getInstance().readSafeUTF(in));
bareJID = (JID) ExternalizableUtil.getInstance().readSerializable(in);
nickname = ExternalizableUtil.getInstance().readSafeUTF(in);
}
}
......@@ -80,7 +80,7 @@ public class DestroyRoomRequest extends MUCRoomTask {
super.writeExternal(out);
ExternalizableUtil.getInstance().writeBoolean(out, alternateJID != null);
if (alternateJID != null) {
ExternalizableUtil.getInstance().writeSafeUTF(out, alternateJID.toFullJID());
ExternalizableUtil.getInstance().writeSerializable(out, alternateJID);
}
ExternalizableUtil.getInstance().writeBoolean(out, reason != null);
if (reason != null) {
......@@ -92,7 +92,7 @@ public class DestroyRoomRequest extends MUCRoomTask {
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
super.readExternal(in);
if (ExternalizableUtil.getInstance().readBoolean(in)) {
alternateJID = new JID(ExternalizableUtil.getInstance().readSafeUTF(in));
alternateJID = (JID) ExternalizableUtil.getInstance().readSerializable(in);
}
if (ExternalizableUtil.getInstance().readBoolean(in)) {
reason = ExternalizableUtil.getInstance().readSafeUTF(in);
......
......@@ -279,14 +279,14 @@ public class PrivacyList implements Cacheable, Externalizable {
}
public void writeExternal(ObjectOutput out) throws IOException {
ExternalizableUtil.getInstance().writeSafeUTF(out, userJID.toString());
ExternalizableUtil.getInstance().writeSerializable(out, userJID);
ExternalizableUtil.getInstance().writeSafeUTF(out, name);
ExternalizableUtil.getInstance().writeBoolean(out, isDefault);
ExternalizableUtil.getInstance().writeSafeUTF(out, asElement().asXML());
}
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
userJID = new JID(ExternalizableUtil.getInstance().readSafeUTF(in));
userJID = (JID) ExternalizableUtil.getInstance().readSerializable(in);
name = ExternalizableUtil.getInstance().readSafeUTF(in);
isDefault = ExternalizableUtil.getInstance().readBoolean(in);
String xml = ExternalizableUtil.getInstance().readSafeUTF(in);
......
......@@ -57,15 +57,15 @@ public class AffiliationTask extends NodeTask
public void writeExternal(ObjectOutput out) throws IOException
{
super.writeExternal(out);
ExternalizableUtil.getInstance().writeSafeUTF(out, jid.toString());
ExternalizableUtil.getInstance().writeSerializable(out, affiliation);
ExternalizableUtil.getInstance().writeSerializable(out, jid);
ExternalizableUtil.getInstance().writeSerializable(out, affiliation);
}
@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
{
super.readExternal(in);
jid = new JID(ExternalizableUtil.getInstance().readSafeUTF(in));
jid = (JID) ExternalizableUtil.getInstance().readSerializable(in);
affiliation = (NodeAffiliate.Affiliation) ExternalizableUtil.getInstance().readSerializable(in);
}
......
......@@ -64,8 +64,8 @@ public abstract class SubscriptionTask extends NodeTask
{
super.writeExternal(out);
ExternalizableUtil.getInstance().writeSafeUTF(out, subId);
ExternalizableUtil.getInstance().writeSafeUTF(out, owner.toString());
ExternalizableUtil.getInstance().writeSafeUTF(out, subJid.toString());
ExternalizableUtil.getInstance().writeSerializable(out, owner);
ExternalizableUtil.getInstance().writeSerializable(out, subJid);
ExternalizableUtil.getInstance().writeSerializable(out, state);
}
......@@ -74,8 +74,8 @@ public abstract class SubscriptionTask extends NodeTask
{
super.readExternal(in);
subId = ExternalizableUtil.getInstance().readSafeUTF(in);
owner = new JID(ExternalizableUtil.getInstance().readSafeUTF(in));
subJid = new JID(ExternalizableUtil.getInstance().readSafeUTF(in));
owner = (JID) ExternalizableUtil.getInstance().readSerializable(in);
subJid = (JID) ExternalizableUtil.getInstance().readSerializable(in);
state = (State) ExternalizableUtil.getInstance().readSerializable(in);
}
......
......@@ -538,7 +538,7 @@ public class RosterItem implements Cacheable, Externalizable {
}
public void writeExternal(ObjectOutput out) throws IOException {
ExternalizableUtil.getInstance().writeSafeUTF(out, jid.toString());
ExternalizableUtil.getInstance().writeSerializable(out, jid);
ExternalizableUtil.getInstance().writeBoolean(out, nickname != null);
if (nickname != null) {
ExternalizableUtil.getInstance().writeSafeUTF(out, nickname);
......@@ -553,7 +553,7 @@ public class RosterItem implements Cacheable, Externalizable {
}
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
jid = new JID(ExternalizableUtil.getInstance().readSafeUTF(in));
jid = (JID) ExternalizableUtil.getInstance().readSerializable(in);
if (ExternalizableUtil.getInstance().readBoolean(in)) {
nickname = ExternalizableUtil.getInstance().readSafeUTF(in);
}
......
......@@ -94,12 +94,12 @@ public class ClientSessionTask extends RemoteSessionTask {
public void writeExternal(ObjectOutput out) throws IOException {
super.writeExternal(out);
ExternalizableUtil.getInstance().writeSafeUTF(out, address.toString());
ExternalizableUtil.getInstance().writeSerializable(out, address);
}
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
super.readExternal(in);
address = new JID(ExternalizableUtil.getInstance().readSafeUTF(in));
address = (JID) ExternalizableUtil.getInstance().readSerializable(in);
}
public String toString() {
......
......@@ -80,12 +80,12 @@ public class ComponentSessionTask extends RemoteSessionTask {
public void writeExternal(ObjectOutput out) throws IOException {
super.writeExternal(out);
ExternalizableUtil.getInstance().writeSafeUTF(out, address.toString());
ExternalizableUtil.getInstance().writeSerializable(out, address);
}
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
super.readExternal(in);
address = new JID(ExternalizableUtil.getInstance().readSafeUTF(in));
address = (JID) ExternalizableUtil.getInstance().readSerializable(in);
}
public String toString() {
......
......@@ -85,7 +85,7 @@ public class DeliverRawTextTask implements ClusterTask {
ExternalizableUtil.getInstance().writeInt(out, sessionType.ordinal());
ExternalizableUtil.getInstance().writeBoolean(out, address != null);
if (address != null) {
ExternalizableUtil.getInstance().writeSafeUTF(out, address.toString());
ExternalizableUtil.getInstance().writeSerializable(out, address);
}
ExternalizableUtil.getInstance().writeBoolean(out, streamID != null);
if (streamID != null) {
......@@ -97,7 +97,7 @@ public class DeliverRawTextTask implements ClusterTask {
text = ExternalizableUtil.getInstance().readSafeUTF(in);
sessionType = SessionType.values()[ExternalizableUtil.getInstance().readInt(in)];
if (ExternalizableUtil.getInstance().readBoolean(in)) {
address = new JID(ExternalizableUtil.getInstance().readSafeUTF(in));
address = (JID) ExternalizableUtil.getInstance().readSerializable(in);
}
if (ExternalizableUtil.getInstance().readBoolean(in)) {
streamID = ExternalizableUtil.getInstance().readSafeUTF(in);
......
......@@ -65,12 +65,12 @@ public class OutgoingServerSessionTask extends RemoteSessionTask {
public void writeExternal(ObjectOutput out) throws IOException {
super.writeExternal(out);
ExternalizableUtil.getInstance().writeSafeUTF(out, address.toString());
ExternalizableUtil.getInstance().writeSerializable(out, address);
}
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
super.readExternal(in);
address = new JID(ExternalizableUtil.getInstance().readSafeUTF(in));
address = (JID) ExternalizableUtil.getInstance().readSerializable(in);
}
public String toString() {
......
......@@ -85,7 +85,7 @@ public class ProcessPacketTask implements ClusterTask {
public void writeExternal(ObjectOutput out) throws IOException {
ExternalizableUtil.getInstance().writeBoolean(out, address != null);
if (address != null) {
ExternalizableUtil.getInstance().writeSafeUTF(out, address.toString());
ExternalizableUtil.getInstance().writeSerializable(out, address);
}
ExternalizableUtil.getInstance().writeBoolean(out, streamID != null);
if (streamID != null) {
......@@ -104,7 +104,7 @@ public class ProcessPacketTask implements ClusterTask {
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
if (ExternalizableUtil.getInstance().readBoolean(in)) {
address = new JID(ExternalizableUtil.getInstance().readSafeUTF(in));
address = (JID) ExternalizableUtil.getInstance().readSerializable(in);
}
if (ExternalizableUtil.getInstance().readBoolean(in)) {
streamID = ExternalizableUtil.getInstance().readSafeUTF(in);
......
......@@ -256,12 +256,12 @@ public class RemoteComponentSession extends RemoteSession implements ComponentSe
public void writeExternal(ObjectOutput out) throws IOException {
super.writeExternal(out);
ExternalizableUtil.getInstance().writeSafeUTF(out, componentJID.toString());
ExternalizableUtil.getInstance().writeSerializable(out, componentJID);
}
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
super.readExternal(in);
componentJID = new JID(ExternalizableUtil.getInstance().readSafeUTF(in));
componentJID = (JID) ExternalizableUtil.getInstance().readSerializable(in);
}
}
}
......@@ -106,12 +106,12 @@ public class ClientSessionTask extends RemoteSessionTask {
public void writeExternal(ObjectOutput out) throws IOException {
super.writeExternal(out);
ExternalizableUtil.getInstance().writeSafeUTF(out, address.toString());
ExternalizableUtil.getInstance().writeSerializable(out, address);
}
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
super.readExternal(in);
address = new JID(ExternalizableUtil.getInstance().readSafeUTF(in));
address = (JID) ExternalizableUtil.getInstance().readSerializable(in);
}
public String toString() {
......
......@@ -80,12 +80,12 @@ public class ComponentSessionTask extends RemoteSessionTask {
public void writeExternal(ObjectOutput out) throws IOException {
super.writeExternal(out);
ExternalizableUtil.getInstance().writeSafeUTF(out, address.toString());
ExternalizableUtil.getInstance().writeSerializable(out, address);
}
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
super.readExternal(in);
address = new JID(ExternalizableUtil.getInstance().readSafeUTF(in));
address = (JID) ExternalizableUtil.getInstance().readSerializable(in);
}
public String toString() {
......
......@@ -85,7 +85,7 @@ public class DeliverRawTextTask implements ClusterTask {
ExternalizableUtil.getInstance().writeInt(out, sessionType.ordinal());
ExternalizableUtil.getInstance().writeBoolean(out, address != null);
if (address != null) {
ExternalizableUtil.getInstance().writeSafeUTF(out, address.toString());
ExternalizableUtil.getInstance().writeSerializable(out, address);
}
ExternalizableUtil.getInstance().writeBoolean(out, streamID != null);
if (streamID != null) {
......@@ -97,7 +97,7 @@ public class DeliverRawTextTask implements ClusterTask {
text = ExternalizableUtil.getInstance().readSafeUTF(in);
sessionType = SessionType.values()[ExternalizableUtil.getInstance().readInt(in)];
if (ExternalizableUtil.getInstance().readBoolean(in)) {
address = new JID(ExternalizableUtil.getInstance().readSafeUTF(in));
address = (JID) ExternalizableUtil.getInstance().readSerializable(in);
}
if (ExternalizableUtil.getInstance().readBoolean(in)) {
streamID = ExternalizableUtil.getInstance().readSafeUTF(in);
......
......@@ -65,12 +65,12 @@ public class OutgoingServerSessionTask extends RemoteSessionTask {
public void writeExternal(ObjectOutput out) throws IOException {
super.writeExternal(out);
ExternalizableUtil.getInstance().writeSafeUTF(out, address.toString());
ExternalizableUtil.getInstance().writeSerializable(out, address);
}
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
super.readExternal(in);
address = new JID(ExternalizableUtil.getInstance().readSafeUTF(in));
address = (JID) ExternalizableUtil.getInstance().readSerializable(in);
}
public String toString() {
......
......@@ -85,7 +85,7 @@ public class ProcessPacketTask implements ClusterTask {
public void writeExternal(ObjectOutput out) throws IOException {
ExternalizableUtil.getInstance().writeBoolean(out, address != null);
if (address != null) {
ExternalizableUtil.getInstance().writeSafeUTF(out, address.toString());
ExternalizableUtil.getInstance().writeSerializable(out, address);
}
ExternalizableUtil.getInstance().writeBoolean(out, streamID != null);
if (streamID != null) {
......@@ -104,7 +104,7 @@ public class ProcessPacketTask implements ClusterTask {
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
if (ExternalizableUtil.getInstance().readBoolean(in)) {
address = new JID(ExternalizableUtil.getInstance().readSafeUTF(in));
address = (JID) ExternalizableUtil.getInstance().readSerializable(in);
}
if (ExternalizableUtil.getInstance().readBoolean(in)) {
streamID = ExternalizableUtil.getInstance().readSafeUTF(in);
......
......@@ -256,12 +256,12 @@ public class RemoteComponentSession extends RemoteSession implements ComponentSe
public void writeExternal(ObjectOutput out) throws IOException {
super.writeExternal(out);
ExternalizableUtil.getInstance().writeSafeUTF(out, componentJID.toString());
ExternalizableUtil.getInstance().writeSerializable(out, componentJID);
}
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
super.readExternal(in);
componentJID = new JID(ExternalizableUtil.getInstance().readSafeUTF(in));
componentJID = (JID) ExternalizableUtil.getInstance().readSerializable(in);
}
}
}
......@@ -42,14 +42,14 @@ import org.xmpp.packet.Presence;
*/
public class RemotePacketExecution implements ClusterTask {
private JID receipient;
private JID recipient;
private Packet packet;
public RemotePacketExecution() {
}
public RemotePacketExecution(JID receipient, Packet packet) {
this.receipient = receipient;
public RemotePacketExecution(JID recipient, Packet packet) {
this.recipient = recipient;
this.packet = packet;
}
......@@ -60,11 +60,11 @@ public class RemotePacketExecution implements ClusterTask {
public void run() {
// Route packet to entity hosted by this node. If delivery fails then the routing table
// will inform the proper router of the failure and the router will handle the error reply logic
XMPPServer.getInstance().getRoutingTable().routePacket(receipient, packet, false);
XMPPServer.getInstance().getRoutingTable().routePacket(recipient, packet, false);
}
public void writeExternal(ObjectOutput out) throws IOException {
ExternalizableUtil.getInstance().writeSafeUTF(out, receipient.toString());
ExternalizableUtil.getInstance().writeSerializable(out, recipient);
if (packet instanceof IQ) {
ExternalizableUtil.getInstance().writeInt(out, 1);
}
......@@ -78,11 +78,7 @@ public class RemotePacketExecution implements ClusterTask {
}
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
String jid = ExternalizableUtil.getInstance().readSafeUTF(in);
// Optimization that was avoiding the need to reparse and validate JIDs but cannot be done due
// to a change in the JID API. We need to bring this constructor back
//receipient = new JID(jid, true);
receipient = new JID(jid);
recipient = (JID) ExternalizableUtil.getInstance().readSerializable(in);
int packetType = ExternalizableUtil.getInstance().readInt(in);
Element packetElement = (Element) ExternalizableUtil.getInstance().readSerializable(in);
......@@ -100,6 +96,6 @@ public class RemotePacketExecution implements ClusterTask {
}
public String toString() {
return super.toString() + " receipient: " + receipient + "packet: " + packet;
return super.toString() + " recipient: " + recipient + "packet: " + packet;
}
}
\ No newline at end of file
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