Menu

#350 Bullet id from battle record XML file is sometimes -1 causing a NumberFormatException

1.8.1.0
closed
5
2013-03-24
2013-03-06
No

From E-mail:

Hi,

In the battle record XML file, I found:
<bullet id="3--1" ...="">

When I tried to import this XML file into Robocode, an exception occurs.
UncaughtException on thread class java.awt.EventDispatchThread:
java.lang.NumberFormatException: For input string: ""
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at net.sf.robocode.battle.snapshot.BulletSnapshot$1$1.read(BulletSnapshot.java:287)

The code segment responsible for handling the id attribute is unable to parse negative bullet id, it seems.
reader.expect("id", new XmlReader.Attribute() {
public void read(String value) {
String[] parts = value.split("-");
snapshot.ownerIndex = Integer.parseInt(parts[0]);
snapshot.bulletId = Integer.parseInt(parts[1]);
}
});

Angus Lee

Discussion

  • Flemming N. Larsen

    • status: accepted --> closed
     

Log in to post a comment.