Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-users] BadMessageException

I have a catch-all exception handler which sends me an email for unhandled exceptions in case it's due to a bug in the code. Recently I had a flurry of emails because of a URL where someone had entered "/foo?bar=%" ("%" being a typo for "5" in this case):

org.eclipse.jetty.http.BadMessageException: 400: Unable to parse URI query
	at org.eclipse.jetty.server.Request.getParameters(Request.java:454)
	at org.eclipse.jetty.server.Request.getParameter(Request.java:1075)
	at ...

Since this is not due to something in the code, there's nothing I can do about it. If I try "/foo%", I get a 400 response before my code sees it, which is OK.

I'd like to ignore the exception, but I'd prefer not to have to make the code dependent on a class which is Jetty-specific. However, BME is derived from RuntimeException, so I can't just ignore the base class either.

Plan B: Call request.getParameter() inside a try block at the start of request processing, and return a 400 response (as this exception seems to be trying to do) if an exception is thrown. But are there any other gotchas like this that I need to be aware of here? What other exceptions might it throw, and under what circumstances?

Any ideas? What would *you* do in this situation?

--
John English


Back to the top