ahorn / android-rss

Lightweight Android library to parse RSS 2.0 feeds.
529 stars 176 forks source link

Possible bug in MediaAttributes.java, inValue function #32

Closed naba89 closed 8 years ago

naba89 commented 8 years ago

Hi,

I was getting the NumberFormatException while loading the rss feed from [http://spectrum.ieee.org/rss/fulltext] as below:

Caused by: java.lang.NumberFormatException: Invalid int: "" at java.lang.Integer.invalidInt(Integer.java:138) at java.lang.Integer.parseInt(Integer.java:358) at java.lang.Integer.parseInt(Integer.java:334) at org.mcsoxford.rss.MediaAttributes.intValue(MediaAttributes.java:47) at org.mcsoxford.rss.RSSHandler$7.set(RSSHandler.java:210) at org.mcsoxford.rss.RSSHandler.startElement(RSSHandler.java:269) at org.apache.harmony.xml.ExpatParser.startElement(ExpatParser.java:143) at org.apache.harmony.xml.ExpatParser.appendBytes(Native Method) at org.apache.harmony.xml.ExpatParser.parseFragment(ExpatParser.java:513) at org.apache.harmony.xml.ExpatParser.parseDocument(ExpatParser.java:474) at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:316) at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:279) at org.mcsoxford.rss.RSSParser.parse(RSSParser.java:96) at org.mcsoxford.rss.RSSParser.parse(RSSParser.java:65) at org.mcsoxford.rss.RSSReader.load(RSSReader.java:107)

Caused by an empty string. The only check done in intValue function is for a null string. Added check for empty string to return the default value for my local version. if((value == null) || (value.isEmpty())) { return defaultValue; }

Regards Nabarun

ahorn commented 8 years ago

Hi Nabarun,

Thanks for reporting this. If you send a pull request, I'll merge it.

ahorn commented 8 years ago

Thank you Nabarun. Next time please include a unit test.