taycaldwell / riot-api-java

Riot Games API Java Library
http://taycaldwell.github.io/riot-api-java/
Apache License 2.0
192 stars 73 forks source link

Error with GetDataChampionbyId #119

Closed pquadri closed 7 years ago

pquadri commented 7 years ago

For some reason I can't use the api with any way, I always get a "null pointer exception" on the call to the api even if i just put as arguments Platform.EUW and 7 (which is supposed to be Leblanc). Same problem with the method to get the whole list of champions.

drunderscore commented 7 years ago

What code are you executing to access the api? What were you running that causes the NPE?

pquadri commented 7 years ago

"RiotApi api = new RiotApi(config); api.getDataChampion(Platform.EUW, 7);”

This is enough to cause the bug for me

On 22 Sep 2017, at 16:11, James Puleo notifications@github.com wrote:

What code are you executing to access the api? What were you running that causes the NPE?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/taycaldwell/riot-api-java/issues/119#issuecomment-331458257, or mute the thread https://github.com/notifications/unsubscribe-auth/AIyFpprn8wgf4mBohaxsOk4HKkqXi2q2ks5sk8AlgaJpZM4PgvGP.

drunderscore commented 7 years ago

Is it just your token in the config? Does the API throw any exceptions before the NPE occurs?

Post the entire stacktrace.

pquadri commented 7 years ago

Ye it’s just the token. (it’s line 429 because it’s a bunch of commented code, I just left the declaration of the API and the call to the function)

Exception in thread "main" java.lang.NullPointerException at net.rithms.riot.api.UrlParameter.(UrlParameter.java:46) at net.rithms.riot.api.endpoints.static_data.methods.GetDataChampion.(GetDataChampion.java:42) at net.rithms.riot.api.RiotApi.getDataChampion(RiotApi.java:552) at net.rithms.riot.api.RiotApi.getDataChampion(RiotApi.java:570) at LOLScouter.main(LOLScouter.java:429)

On 22 Sep 2017, at 18:58, James Puleo notifications@github.com wrote:

Is it just your token in the config? Does the API throw any exceptions before the NPE occurs?

Post the entire stacktrace.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/taycaldwell/riot-api-java/issues/119#issuecomment-331502656, or mute the thread https://github.com/notifications/unsubscribe-auth/AIyFpuaMRxxnRs5WosdOky_LZmEDOjAVks5sk-c3gaJpZM4PgvGP.

taycaldwell commented 7 years ago

What release version are you using?

drunderscore commented 7 years ago

Not home right now, although @taycaldwell should be able to help you out.

pquadri commented 7 years ago

4.0.0. Was waiting for example to pass onto 4.0.2. Is that the problem?

Paolo Quadri

Il giorno 22 set 2017, alle ore 19:23, Taylor Caldwell notifications@github.com ha scritto:

What release are you using?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

taycaldwell commented 7 years ago

I believe this bug was previously reported and fixed in 4.0.1.

https://github.com/taycaldwell/riot-api-java/issues/113

pquadri commented 7 years ago

Didn’t find it in the changelog. Will try it later. I tried before using the 4.0.2 but apparently I’m having problems with the limitator

Thank you very much!

Paolo Quadri

Il giorno 22 set 2017, alle ore 20:53, Taylor Caldwell notifications@github.com ha scritto:

I believe this bug was previously reported and fixed in 4.0.1.

113

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

pquadri commented 7 years ago

The null pointer got fixed by updating the version but i still get the rate limit exceeded even by just calling getDataChampionList once

(just Map<String, Champion> championList = api.getDataChampionList(Platform.EUW).getData(); is enough to trigger it)

Exception in thread "main" net.rithms.riot.api.request.ratelimit.RateLimitException: Rate limit exceeded (Type: method; Retry After: 3381) at net.rithms.riot.api.request.Request.execute(Request.java:191) at net.rithms.riot.api.request.Request.(Request.java:94) at net.rithms.riot.api.EndpointManager.callMethodAndReturnDto(EndpointManager.java:52) at net.rithms.riot.api.RiotApi.getDataChampionList(RiotApi.java:603) at net.rithms.riot.api.RiotApi.getDataChampionList(RiotApi.java:618) at LOLScouter.getRankedStatsByData(LOLScouter.java:364) at LOLScouter.main(LOLScouter.java:465)

On 23 Sep 2017, at 01:20, Taylor Caldwell notifications@github.com wrote:

Closed #119 https://github.com/taycaldwell/riot-api-java/issues/119.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/taycaldwell/riot-api-java/issues/119#event-1262104813, or mute the thread https://github.com/notifications/unsubscribe-auth/AIyFpudUYvz_k33UzCsOE4-eolYVoV6kks5slEDWgaJpZM4PgvGP.

Linnun commented 7 years ago

Please note that static data endpoints are limited to 10 calls per hour. So if you already did a hand full of tests with that key in the past hour, you may have reached that limit already. For more information on rate limiting, please refer to: https://developer.riotgames.com/rate-limiting.html

pquadri commented 7 years ago

Worked around that by caching the champion list to a file, I honestly didn't know there was another limit for these kind of calls.

Linnun commented 7 years ago

You should probably try to cache all kinds of calls - at least for the short term. Static data in particular can (and should) also be cached long term, since that data is probably not going to change until the next patch. (approx. 14 day cycle)

pquadri commented 7 years ago

yes i'm caching all the static data now, my problem is i need updated matchlist on every run of the function so i can't really cache that

2017-09-25 20:16 GMT+02:00 Linnun notifications@github.com:

You should probably try to cache all kinds of calls - at least for the short term. Static data in particular can (and should) also be cached long term, since that data is probably not going to change until the next patch. (approx. 14 day cycle)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/taycaldwell/riot-api-java/issues/119#issuecomment-331967591, or mute the thread https://github.com/notifications/unsubscribe-auth/AIyFpv0xbiM11KWWWh6przhEQHcmjNR-ks5sl-32gaJpZM4PgvGP .

-- Paolo Quadri

taycaldwell commented 7 years ago

IMO, for most use cases, match data should be persisted long term as well, as the only thing that changes is new games since the last query. If you need to hit the endpoint often and find yourself reaching your rate limit, you may need to get creative and design your app in a way that doesn't require you to hit your limit as often. A good example of apps that do this is OP.gg's 'Update' button for summoner profiles. Only data users truly care about is requested and it is cached for later use.

If you can't get the data you need for your current project with your current limit, that is a discussion you will need to have with Riot, as we cannot do anything about that.