meraki-analytics / orianna

A Java framework for the Riot Games League of Legends API (http://developer.riotgames.com/).
MIT License
182 stars 56 forks source link

Null Pointer on Participant.getSummoner #11

Closed EntilZha closed 9 years ago

EntilZha commented 9 years ago

Been working at the Riot API challenge and found null pointer bug. Below is an example (in Scala though, but it translates fine):

val m: Match = //somehow retrieve a match
val participant: Participant = m.getParticipants()(0)
participant.getSummoner // This throws Null pointer

Here is the stack trace:

[error] (run-main-3) java.lang.NullPointerException
java.lang.NullPointerException
    at com.robrua.orianna.type.core.match.Participant.getSummoner(Participant.java:164)
    at RitoAkka$.featurizeParticipant(RitoAkka.scala:84)
    at RitoAkka$$anonfun$5.apply(RitoAkka.scala:49)
    at RitoAkka$$anonfun$5.apply(RitoAkka.scala:49)
    at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:245)
    at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:245)
    at scala.collection.mutable.ResizableArray$class.foreach(ResizableArray.scala:59)
    at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:48)
    at scala.collection.TraversableLike$class.map(TraversableLike.scala:245)
    at scala.collection.AbstractTraversable.map(Traversable.scala:104)
    at RitoAkka$.extractMatchFeatures(RitoAkka.scala:49)
    at RitoAkka$$anonfun$18.apply(RitoAkka.scala:188)
    at RitoAkka$$anonfun$18.apply(RitoAkka.scala:188)
    at scala.collection.immutable.List.map(List.scala:273)
    at RitoAkka$.main(RitoAkka.scala:188)
    at RitoAkka.main(RitoAkka.scala)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)

I am using the most recent snapshot (might give a try to build/compiling master if that would help), but based on that error message, I looked https://github.com/robrua/Orianna/blob/master/src/com/robrua/orianna/type/core/match/Participant.java#L164

The debugger says that getPlayer returns a null value. At this point, I have only briefly looked at the orianna source code so I don't have a good idea what is wrong, but will probably looking at it more later today. Any ideas in the meanwhile?

robrua commented 9 years ago

Hey,

Thanks for the report.

Currently the fact that Riot didn't send identity data for the players in the JSON payload isn't handled correctly here. All that really needs to be added is a check for whether the data is null. I can't fix this right now, but will update it later today.

FYI, the most recent snapshot (if you got it from robrua.com/orianna) is built automatically on repo update, so building from master won't change anything.

robrua commented 9 years ago

Fixed in newest release/build