Giter Site home page Giter Site logo

raiderrobotix / blue-alliance-api-java-library Goto Github PK

View Code? Open in Web Editor NEW
6.0 2.0 3.0 859 KB

Java library for The Blue Alliance APIv3

Home Page: http://raiderrobotix.github.io/blue-alliance-api-java-library

License: MIT License

Java 100.00%
tba-api frc the-blue-alliance thebluealliance

blue-alliance-api-java-library's People

Contributors

anjaliaravindhan avatar hybras avatar patrick-bruckner avatar spencerng avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

blue-alliance-api-java-library's Issues

NullPointerException with team requests

 Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.thebluealliance.api.v3.requests.APIResponse.getJson()' on a null object reference

My code:

TBA tba = new TBA("key");
Team robot = new Team();
TeamRequest c = tba.teamRequest;
Event[] e = c.getEvents(2658);(the error seems to be directed to this line)
robot = c.getTeam(2658);

Trying to get teams from an event throws IllegalAccessException

When calling getTeams on an EventRequest, the JSON parser will invoke the wrong constructor for Team and result in an IllegalAccessException.

https://github.com/RaiderRobotix/blue-alliance-api-java-library/blob/master/src/main/java/com/thebluealliance/api/v3/requests/EventRequest.java#L57
https://github.com/RaiderRobotix/blue-alliance-api-java-library/blob/master/src/main/java/com/thebluealliance/api/v3/models/Team.java#L17

java.lang.RuntimeException: Failed to invoke com.thebluealliance.api.v3.models.Team() throws java.lang.IllegalAccessException with no args
    at com.google.gson.internal.ConstructorConstructor$3.construct(ConstructorConstructor.java:118)
Caused by: java.lang.IllegalAccessException: You've called the constructor of Team
    at com.thebluealliance.api.v3.models.Team.<init>(Team.java:17)

Unhandled NullPointerException if a team number or event code does not exist

When passing in a team number to TeamRequest.getTeam(), the method .getJson() is called on the API response, which will cause a NullPointerException if the team number does not exist. The same result will happen if an invalid event code is provided, or any other similar invalid parameter. Since the method does not handle the exception, there is no way for the implementer to handle the exception. Perhaps the methods should throw NullPointerException, that way the implementer can catch the Exception in the event the team number does not exist.

https://github.com/RaiderRobotix/blue-alliance-api-java-library/blob/master/src/main/java/com/thebluealliance/api/v3/requests/TeamRequest.java#L34

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.