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

Occasional ArrayIndexOutOfBoundsException due to SimpleDateFormat use #184

mdeeks opened this Issue Feb 4, 2015 · 2 comments


None yet
3 participants

mdeeks commented Feb 4, 2015

We're heavily using jolokia in our environment for monitoring purposes. Occasionally jolokia dies and returns 500s with the exception pasted below. I'm guessing it is due to the re-use of SimpleDateFormat in JolokiaHttpHandler. From the Javadocs: "Date formats are not synchronized. It is recommended to create separate format instances for each thread. If multiple threads access a format concurrently, it must be synchronized externally."

Once jolokia gets into this state it does not recover without restarting the process. Here is the exception I get when doing a GET /jolokia/version on one of the broken instances:

java.lang.ArrayIndexOutOfBoundsException: -2147483648
    at java.util.Calendar.getDisplayName(
    at java.text.SimpleDateFormat.subFormat(
    at java.text.SimpleDateFormat.format(
    at java.text.SimpleDateFormat.format(
    at java.text.DateFormat.format(
    at org.jolokia.jvmagent.JolokiaHttpHandler.setHeaders(
    at org.jolokia.jvmagent.JolokiaHttpHandler.handle(
    at java.util.concurrent.ThreadPoolExecutor.runWorker(

This comment has been minimized.


rhuss commented Mar 3, 2015

Thanks for the report, I will have a look at it. Probably on friday (sorry, busy right now ...)


This comment has been minimized.

markus-meisterernst commented Mar 3, 2015

Hi Roland,

da ich die Sourcen gerade offen hatte ...:

Das SimpleDateFormat ist nicht ThreadSafe. Daher sollte es nicht als Instanzvariable gecached werden (sofern der Zugriff nicht synchronisiert ist).

daher, statt
besser durch:
headers.set("Date",new SimpleDateFormat().format(cal.getTime()));

Hope that helps.



Am 03.03.2015 um 14:42 schrieb Roland Huß

Thanks for the report, I will have a look at it. Probably on friday (sorry, busy right now ...)

Reply to this email directly or view it on GitHub.

@rhuss rhuss closed this in bc08d4b Mar 5, 2015

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