Skip to content

Commit

Permalink
igniterealtime#166: Introduce SAXReaderUtil
Browse files Browse the repository at this point in the history
Using the default SAXReader can be dangerous, if certain properties aren't set. Using a new instance for each stanza that is processed probably requires more resources than is needed. Both issues can be prevented by using `org.jivesoftware.util.SAXReaderUtil`
  • Loading branch information
guusdk committed Mar 15, 2023
1 parent a4b8788 commit e720f5d
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/java/org/jivesoftware/openfire/archive/EmptyMessageType.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package org.jivesoftware.openfire.archive;

import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import org.jivesoftware.util.SAXReaderUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.ByteArrayInputStream;
import java.util.concurrent.ExecutionException;

/**
* Enumeration of types of messages that typically have no body.
Expand Down Expand Up @@ -121,10 +120,9 @@ public enum EmptyMessageType
value = newValue;
}

private static Element parseWithSAX(String xmlString) throws DocumentException
private static Element parseWithSAX(String xmlString) throws ExecutionException, InterruptedException
{
SAXReader xmlReader = new SAXReader();
return xmlReader.read(new ByteArrayInputStream(xmlString.getBytes())).getRootElement();
return SAXReaderUtil.readRootElement(xmlString);
}

public static EmptyMessageType getMessageType(String stanza)
Expand Down

0 comments on commit e720f5d

Please sign in to comment.