jkovacs / lastfm-java

Java bindings for the Last.fm Web Services
BSD 2-Clause "Simplified" License
74 stars 34 forks source link

Problem: the lib is crashing when trying to parse the FIXME string. #6

Closed meoyawn closed 7 years ago

meoyawn commented 7 years ago

Solution: optional int parsing

kgilmer commented 7 years ago

+1

kgilmer commented 7 years ago

Steps to reproduce:

Search last.fm with Track query:

Collection results = Track.search("The Police", "Mother", 10, LAST_FM_API_KEY);

Expected results: An empty or non empty collection returned from search. Actual results: The following stacktrace:

INFO: Post body: method=track.search&limit=10&track=Mother&artist=The+Police&api_key=xyz

java.lang.NumberFormatException: For input string: "FIXME"

at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:580)
at java.lang.Integer.parseInt(Integer.java:615)
at de.umass.lastfm.MusicEntry.loadStandardInfo(MusicEntry.java:207)
at de.umass.lastfm.Track$TrackFactory.createItemFromElement(Track.java:697)
at de.umass.lastfm.Track$TrackFactory.createItemFromElement(Track.java:694)
at de.umass.lastfm.ResponseBuilder.buildCollection(ResponseBuilder.java:70)
at de.umass.lastfm.ResponseBuilder.buildCollection(ResponseBuilder.java:61)
at de.umass.lastfm.Track.search(Track.java:216)

...

kgilmer commented 7 years ago

I have verified adelnizamutdinov's fix by consuming a release (https://github.com/kgilmer/lastfm-java/releases/tag/0.1.3) with it into my project via jitpack.

AnujDutt2701 commented 7 years ago

I'm still not sure how I include your solution to my project. :(

meoyawn commented 7 years ago

@AnujDutt2701 use https://jitpack.io/#adelnizamutdinov/lastfm-java/827407b4e2

AnujDutt2701 commented 7 years ago

@adelnizamutdinov I still get the same error.

AnujDutt2701 commented 7 years ago

Any other fix that may be available for this? I'm stuck at the moment,

jkovacs commented 7 years ago

Thanks for this fix, merging this now finally.

I believe an easier fix for this issue would be to replace the whole definition with just boolean streamable = "1".equals(s); so feel free to update this PR later.