restlet-framework-java icon indicating copy to clipboard operation
restlet-framework-java copied to clipboard

NullPointerException is thrown when HeaderUtils.getContentLength is called

Open koalalam opened this issue 8 years ago • 3 comments

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?

koalalam avatar Dec 06 '16 15:12 koalalam

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 avatar Dec 10 '16 13:12 thboileau

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

thboileau avatar Dec 10 '16 14:12 thboileau

What's the update on this issue?

sheltshamu avatar Aug 13 '23 16:08 sheltshamu