Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException is thrown when HeaderUtils.getContentLength is called #1250

Open
koalalam opened this issue Dec 6, 2016 · 3 comments
Open

Comments

@koalalam
Copy link

koalalam commented Dec 6, 2016

Version: SE, 2.3.3

This was actually caused by mysterious access to our system - here is stacktrace:

at org.restlet.engine.header.HeaderUtils.getContentLength(HeaderUtils.java:940)
at org.restlet.engine.adapter.ServerCall.getContentLength(ServerCall.java:143)
at org.restlet.engine.adapter.ServerCall.getRequestEntity(ServerCall.java:179)
at org.restlet.engine.adapter.HttpRequest.getEntity(HttpRequest.java:539)
at org.restlet.engine.application.Decoder.beforeHandle(Decoder.java:115)
at org.restlet.routing.Filter.handle(Filter.java:195)
at org.restlet.routing.Filter.doHandle(Filter.java:150)
at org.restlet.engine.application.StatusFilter.doHandle(StatusFilter.java:140)

Looking at the source code (HeaderUtils.java:940), the NullPointerException is thrown from this line:

if (header.getName().equalsIgnoreCase( // Line 940

So, either "header" or "header.getName()" is NULL, but not sure under what situation would that be.

Any idea?

@thboileau
Copy link
Contributor

Hello,

from the point the of view of the framework code, I see that the header's name can be set in two ways:

  • a constructor, called once by a deprecated method which is never called
  • the setter, called twice, (in HeaderReader class); in these cases, it is impossible to set a null value

So, either somewhere some part of your code set the header name, or the header is null.
I check the latter point.

@thboileau
Copy link
Contributor

Hello @koalalam

this is not easy to check. Actually, this is the first time this kind of bug is reported, as far as I can remember.
does it happen on a regular basis? Do you use the internal server connector or another one such as Jetty, simple, or from a servlet container?

Best regards

@sheltshamu
Copy link

What's the update on this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants