Selasa, 27 Juli 2021

Avoid Using System.exit() on Java Web Application - Best Practice

I have recently come across a code snippet, where the programmer was using System.exit() if the application failed to acquire necessary resources after a couple of retries. His reasoning was that the application cannot function if essential resources like the database are not available or there is no disk space to write records in the File system. Ok, I hear you; but System.exit() in Java Web application, which runs inside either web server or application server, which itself is Java program is not a good idea at all. Why? because invoking System.exit() kills your JVM, invoking this from Tomcat or Jetty, will not only kill your application but the most likely server itself. This can be potentially dangerous if that server also hosts other critical applications, which is not uncommon at all.

Lorem ipsum is simply dummy text of the printing and typesetting industry.

Comments


EmoticonEmoticon