Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
0.24.0
-
None
-
None
-
Reviewed
-
Reduce number of object created by JMXJsonServlet. (Devaraj K via Eric Yang)
Description
1. Currently JMXJsonServlet creates JsonFactory for every http request.
Its not efficient.
JsonFactory can be created only once and used for every next request to create JsonGenerator.
2. Also following null check is not required.
if (mBeanServer == null) { jg.writeStringField("result", "ERROR"); jg.writeStringField("message", "No MBeanServer could be found"); jg.close(); LOG.error("No MBeanServer could be found."); response.setStatus(HttpServletResponse.SC_NOT_FOUND); return; }
Because ManagementFactory.getPlatformMBeanServer(); will not return null.
3. Move the following code to finally so that any exception should not cause skipping of close method on JsonGenerator
jg.close();