Skip to content

Commit 721c20f

Browse files
author
Erno Mononen
committed
Fix handling of messages/errors for empty variables/threads/frames, e.g. for cases like <variables><message></variables>.
1 parent 8c6b5f0 commit 721c20f

File tree

4 files changed

+44
-0
lines changed

4 files changed

+44
-0
lines changed

src/org/rubyforge/debugcommons/Util.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,4 +266,19 @@ public static String getType(final XmlPullParser xpp) {
266266
return "<Unable to find a type>";
267267
}
268268
}
269+
270+
/**
271+
* Checks whether the current state of the given <code>xpp</code> represents
272+
* an end tag for the given <code>name</code>.
273+
*
274+
* @param xpp
275+
* @param name
276+
* @return
277+
* @throws XmlPullParserException
278+
* @throws IOException
279+
*/
280+
public static boolean isEndTag(XmlPullParser xpp, String name) throws XmlPullParserException, IOException {
281+
return XmlPullParser.END_TAG == xpp.getEventType() && name.equals(xpp.getName());
282+
}
283+
269284
}

src/org/rubyforge/debugcommons/reader/FramesReader.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import java.io.IOException;
2626
import java.util.ArrayList;
2727
import java.util.List;
28+
import org.rubyforge.debugcommons.Util;
2829
import org.rubyforge.debugcommons.model.RubyFrameInfo;
2930
import org.xmlpull.v1.XmlPullParser;
3031
import org.xmlpull.v1.XmlPullParserException;
@@ -42,6 +43,15 @@ private void parse() throws XmlPullParserException, IOException {
4243
assert xpp.getName().equals("frames");
4344
while (!(nextEvent() == XmlPullParser.END_TAG && "frames".equals(xpp.getName()))) {
4445
ErrorReader.flushPossibleMessage(xpp);
46+
/*
47+
* Check for empty <frames>, e.g.:
48+
* <frames>
49+
* <message>
50+
* </frames>
51+
*/
52+
if (Util.isEndTag(xpp, "frames")) {
53+
break;
54+
}
4555
assert xpp.getName().equals("frame") : xpp.getName() + " encountered";
4656
String file = getAttributeValue("file");
4757
int line = getAttributeIntValue("line");

src/org/rubyforge/debugcommons/reader/ThreadInfoReader.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import java.io.IOException;
2626
import java.util.ArrayList;
2727
import java.util.List;
28+
import org.rubyforge.debugcommons.Util;
2829
import org.rubyforge.debugcommons.model.RubyThreadInfo;
2930
import org.xmlpull.v1.XmlPullParser;
3031
import org.xmlpull.v1.XmlPullParserException;
@@ -42,6 +43,15 @@ private void parse() throws XmlPullParserException, IOException {
4243
assert xpp.getName().equals("threads");
4344
while (!(nextEvent() == XmlPullParser.END_TAG && "threads".equals(xpp.getName()))) {
4445
ErrorReader.flushPossibleMessage(xpp);
46+
/*
47+
* Check for empty <threads>, e.g.:
48+
* <threads>
49+
* <message>
50+
* </threads>
51+
*/
52+
if (Util.isEndTag(xpp, "threads")) {
53+
break;
54+
}
4555
assert xpp.getName().equals("thread") : xpp.getName() + " encountered";
4656
int id = getAttributeIntValue("id");
4757
String status = getAttributeValue("status");

src/org/rubyforge/debugcommons/reader/VariablesReader.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,15 @@ private void parseVariables() throws XmlPullParserException, IOException {
6464
"and file a bug against Ruby or debug-commons tracker.");
6565
}
6666
ErrorReader.flushPossibleMessage(xpp);
67+
/*
68+
* Check for empty <variables>, e.g.:
69+
* <variables>
70+
* <message>
71+
* </variables>
72+
*/
73+
if (Util.isEndTag(xpp, "variables")) {
74+
break;
75+
}
6776
assert xpp.getName().equals("variable") : xpp.getName() + "(type: " + Util.getType(xpp) + ") encountered";
6877
String name = getAttributeValue("name");
6978
String value = getAttributeValue("value");

0 commit comments

Comments
 (0)