Skip to content

AnnotatorPlus returns 500 with NPE on every request #11

Description

@jvendetti

Affected: services.data.bioontology.org/annotatorplus (BioPortal production)
Deployed version: org.sifrproject:sifr-bioportal-annotator-proxy:0.1-SNAPSHOT

Reproduction

Via curl:

$ curl -sL -H "Authorization: apikey token=<YOUR_API_KEY>" \
    "https://services.data.bioontology.org/annotatorplus?text=probiotics"

Returns HTTP 500 with the following stack trace embedded in the response body:

java.lang.NullPointerException
    at java.base/java.io.Reader.<init>(Reader.java:167)
    at java.base/java.io.InputStreamReader.<init>(InputStreamReader.java:93)
    at org.sifrproject.util.RestfulRequest.streamAsString(RestfulRequest.java:60)
    at org.sifrproject.util.RestfulRequest.queryAnnotator(RestfulRequest.java:27)
    at org.sifrproject.servlet.AnnotatorServlet.doPost(AnnotatorServlet.java:175)
    at org.sifrproject.servlet.AnnotatorServlet.doGet(AnnotatorServlet.java:118)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:529)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:623)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
    at org.sifrproject.util.CharacterSetFilter.doFilter(CharacterSetFilter.java:24)

Via the UI: navigate to the AnnotatorPlus page, insert the sample text, and click "Get annotations". The Rails application displays: Problem getting annotations, please try again.

Diagnosis

The NPE is the visible symptom, not the root cause. Initial investigation suggests the proxy is hitting an upstream redirect (HTTPS → HTTP) that Java's HttpURLConnection refuses to follow by default, and the response-handling code in RestfulRequest.queryAnnotator doesn't tolerate the resulting state — it calls getErrorStream() on a 3xx response, which returns null, and streamAsString(null) then NPEs in the InputStreamReader constructor.

Relates to: ncbo/ontologies_api#217

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions