aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel.gultsch@rwth-aachen.de>2014-04-18 01:07:45 +0200
committerDaniel Gultsch <daniel.gultsch@rwth-aachen.de>2014-04-18 01:07:45 +0200
commit625fbe7d816ea2bc570cd0454ecf449e2b4c622b (patch)
tree5167cadb90af4a5bf697bc08e021550244bb24fa /src/eu
parent07cf07ad58b9e99d9b63da1e00529c4e3bda721f (diff)
parent18c0c31b65ba488c1087441cefb76090dfb26084 (diff)
Merge branch 'master' into development
Diffstat (limited to 'src/eu')
-rw-r--r--src/eu/siacs/conversations/xml/XmlReader.java46
1 files changed, 25 insertions, 21 deletions
diff --git a/src/eu/siacs/conversations/xml/XmlReader.java b/src/eu/siacs/conversations/xml/XmlReader.java
index 71e86cf9c..0a82a5d89 100644
--- a/src/eu/siacs/conversations/xml/XmlReader.java
+++ b/src/eu/siacs/conversations/xml/XmlReader.java
@@ -51,32 +51,36 @@ public class XmlReader {
public Tag readTag() throws XmlPullParserException, IOException {
if (wakeLock.isHeld()) {
- wakeLock.release(); //release wake look while waiting on next parser event
+ wakeLock.release();
}
- while(parser.next() != XmlPullParser.END_DOCUMENT) {
- wakeLock.acquire();
- if (parser.getEventType() == XmlPullParser.START_TAG) {
- Tag tag = Tag.start(parser.getName());
- for(int i = 0; i < parser.getAttributeCount(); ++i) {
- tag.setAttribute(parser.getAttributeName(i), parser.getAttributeValue(i));
- }
- String xmlns = parser.getNamespace();
- if (xmlns!=null) {
- tag.setAttribute("xmlns",xmlns);
+ try {
+ while(parser.next() != XmlPullParser.END_DOCUMENT) {
+ wakeLock.acquire();
+ if (parser.getEventType() == XmlPullParser.START_TAG) {
+ Tag tag = Tag.start(parser.getName());
+ for(int i = 0; i < parser.getAttributeCount(); ++i) {
+ tag.setAttribute(parser.getAttributeName(i), parser.getAttributeValue(i));
+ }
+ String xmlns = parser.getNamespace();
+ if (xmlns!=null) {
+ tag.setAttribute("xmlns",xmlns);
+ }
+ return tag;
+ } else if (parser.getEventType() == XmlPullParser.END_TAG) {
+ Tag tag = Tag.end(parser.getName());
+ return tag;
+ } else if (parser.getEventType() == XmlPullParser.TEXT) {
+ Tag tag = Tag.no(parser.getText());
+ return tag;
}
- return tag;
- } else if (parser.getEventType() == XmlPullParser.END_TAG) {
- Tag tag = Tag.end(parser.getName());
- return tag;
- } else if (parser.getEventType() == XmlPullParser.TEXT) {
- Tag tag = Tag.no(parser.getText());
- return tag;
}
+ if (wakeLock.isHeld()) {
+ wakeLock.release();
}
- if (wakeLock.isHeld()) {
- wakeLock.release();
+ } catch (ArrayIndexOutOfBoundsException e) {
+ throw new IOException("xml parser mishandled ArrayIndexOufOfBounds", e);
}
- return null; //end document;
+ return null;
}
public Element readElement(Tag currentTag) throws XmlPullParserException, IOException {