HTTP Status 7XX

Ever wanted to return obscure HTTP Status codes from your Jersey REST application?

Now you can easily get all HTTP Status codes from the 7XX ranged as proposed by some people at RailsCamp ( see spec ) just grab the status codes from here at github or pull em in as maven dependency with

<dependency>
  <groupId>be.redlab.jersey</groupId>
  <artifactId>http-7xx</artifactId>
  <version>1.0</version>
</dependency>

You can just send it with Jersey’s response like return

Response.status(HttpStatus7xx.A_KITTEN_DIES).build();

I know that Tomcat will not send the reason phrase. By default tomcat does not allow to set custom messages for statusses. To get tomcat to send the custom message you have to add a parameter at startup set

-Dorg.apache.coyote.USE_CUSTOM_STATUS_MSG_IN_HEADER=true

and you will have the status message in your response.

I haven’t tested with other containers yet.

Have fun with 7XX !

Watch out when you pool things!

Last two weeks our operations team had to do daily restarts of a site that has between 800K to 1M hits per day. At a certain point, the webservers couldn’t take more connections, died and had to be restarted.

To detect the problem they tried to simulate the same behaviour on an a staging environment but we never succeeded in bringing those down. It took the team two weeks to simulate the exact same behaviour. Which in fact was a combination of a back end search service that performed a re-indexing operation and a bug in the client used to request data from that engine. ( A search request to the search engine happens with 7 on 10 of the hits)
At a certain point of the indexing the search engine started to spit out exceptions responses instead of the only expected result response. The application code that requests data from that search engine was recently changed to use a pool of JAXB Unmarshallers from javax.xml.bind.JAXBContext instead of creating new unmarshallers on the fly.
As you may know, or may not know and then you know now, Continue reading “Watch out when you pool things!”

A small survey about logging in Java

Help me conduct a small survey about logging in the Java Eco System!

Fill in the survey! Results will be published in the next month.