Hi, 2015-12-18 13:46 GMT+02:00 Mark Thomas <ma...@apache.org>: > > On 18/12/2015 11:42, ma...@apache.org wrote: > > Author: markt > > Date: Fri Dec 18 11:42:18 2015 > > New Revision: 1720759 > > > > URL: http://svn.apache.org/viewvc?rev=1720759&view=rev > > Log: > > Formatting. No functional change. > > I'm looking into some issues reported by Coverity in this class so I > wanted to clean up the formatting first. I used Eclipse's built-in code > formatter with some custom settings so I'd be interested in what folks > think of the result. > I'm not planning on applying the formatter across the whole code base, > rather I'm considering using it as a quick fix to get the format 95% > right when there is a large amount of format clean-up required. > > Mark > > > > > Modified: > > tomcat/trunk/java/org/apache/catalina/manager/JMXProxyServlet.java > > > > Modified: tomcat/trunk/java/org/apache/catalina/manager/JMXProxyServlet.java > > URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/manager/JMXProxyServlet.java?rev=1720759&r1=1720758&r2=1720759&view=diff > > ============================================================================== > > --- tomcat/trunk/java/org/apache/catalina/manager/JMXProxyServlet.java (original) > > +++ tomcat/trunk/java/org/apache/catalina/manager/JMXProxyServlet.java Fri Dec 18 11:42:18 2015 > > @@ -38,12 +38,12 @@ import org.apache.catalina.mbeans.MBeanD > > import org.apache.tomcat.util.modeler.Registry; > > > > /** > > - * This servlet will dump JMX attributes in a simple format > > - * and implement proxy services for modeler. > > + * This servlet will dump JMX attributes in a simple format and implement proxy > > + * services for modeler. > > * > > * @author Costin Manolache > > */ > > -public class JMXProxyServlet extends HttpServlet { > > +public class JMXProxyServlet extends HttpServlet { > > > > private static final long serialVersionUID = 1L; > > > > @@ -58,6 +58,7 @@ public class JMXProxyServlet extends Htt > > protected transient MBeanServer mBeanServer = null; > > protected transient Registry registry; > > > > + > > // --------------------------------------------------------- Public Methods > > /** > > * Initialize this servlet. > > @@ -80,55 +81,54 @@ public class JMXProxyServlet extends Htt > > * @exception ServletException if a servlet-specified error occurs > > */ > > @Override > > - public void doGet(HttpServletRequest request, > > - HttpServletResponse response) > > - throws IOException, ServletException > > - { > > + public void doGet(HttpServletRequest request, HttpServletResponse response) > > + throws IOException, ServletException {
Are you using the default line width which is 80? Or there is special handling of the format for Exceptions that can be thrown by the method. Regards, Violeta > > response.setContentType("text/plain"); > > > > PrintWriter writer = response.getWriter(); > > > > - if( mBeanServer==null ) { > > + if (mBeanServer == null) { > > writer.println("Error - No mbean server"); > > return; > > } > > > > - String qry=request.getParameter("set"); > > - if( qry!= null ) { > > - String name=request.getParameter("att"); > > - String val=request.getParameter("val"); > > + String qry = request.getParameter("set"); > > + if (qry != null) { > > + String name = request.getParameter("att"); > > + String val = request.getParameter("val"); > > > > - setAttribute( writer, qry, name, val ); > > + setAttribute(writer, qry, name, val); > > return; > > } > > - qry=request.getParameter("get"); > > - if( qry!= null ) { > > - String name=request.getParameter("att"); > > - getAttribute( writer, qry, name, request.getParameter("key") ); > > + qry = request.getParameter("get"); > > + if (qry != null) { > > + String name = request.getParameter("att"); > > + getAttribute(writer, qry, name, request.getParameter("key")); > > return; > > } > > qry = request.getParameter("invoke"); > > - if(qry != null) { > > - String opName=request.getParameter("op"); > > + if (qry != null) { > > + String opName = request.getParameter("op"); > > String[] params = getInvokeParameters(request.getParameter("ps")); > > invokeOperation(writer, qry, opName, params); > > return; > > } > > - qry=request.getParameter("qry"); > > - if( qry == null ) { > > + qry = request.getParameter("qry"); > > + if (qry == null) { > > qry = "*:*"; > > } > > > > - listBeans( writer, qry ); > > + listBeans(writer, qry); > > } > > > > + > > public void getAttribute(PrintWriter writer, String onameStr, String att, String key) { > > try { > > ObjectName oname = new ObjectName(onameStr); > > Object value = mBeanServer.getAttribute(oname, att); > > > > - if(null != key && value instanceof CompositeData) > > - value = ((CompositeData)value).get(key); > > + if (null != key && value instanceof CompositeData) > > + value = ((CompositeData) value).get(key); > > > > String valueStr; > > if (value != null) { > > @@ -142,7 +142,7 @@ public class JMXProxyServlet extends Htt > > writer.print("' - "); > > writer.print(att); > > > > - if(null != key) { > > + if (null != key) { > > writer.print(" - key '"); > > writer.print(key); > > writer.print("'"); > > @@ -157,24 +157,23 @@ public class JMXProxyServlet extends Htt > > } > > } > > > > - public void setAttribute( PrintWriter writer, > > - String onameStr, String att, String val ) > > - { > > + > > + public void setAttribute(PrintWriter writer, String onameStr, String att, String val) { > > try { > > setAttributeInternal(onameStr, att, val); > > writer.println("OK - Attribute set"); > > - } catch( Exception ex ) { > > + } catch (Exception ex) { > > writer.println("Error - " + ex.toString()); > > ex.printStackTrace(writer); > > } > > } > > > > - public void listBeans( PrintWriter writer, String qry ) > > - { > > + > > + public void listBeans(PrintWriter writer, String qry) { > > > > Set<ObjectName> names = null; > > try { > > - names=mBeanServer.queryNames(new ObjectName(qry), null); > > + names = mBeanServer.queryNames(new ObjectName(qry), null); > > writer.println("OK - Number of results: " + names.size()); > > writer.println(); > > } catch (Exception ex) { > > @@ -187,11 +186,12 @@ public class JMXProxyServlet extends Htt > > writer.print(dump); > > } > > > > + > > /** > > * Determines if a type is supported by the {@link JMXProxyServlet}. > > * > > - * @param type The type to check > > - * @return Always returns <code>true</code> > > + * @param type The type to check > > + * @return Always returns <code>true</code> > > */ > > public boolean isSupported(String type) { > > return true; > > @@ -208,7 +208,7 @@ public class JMXProxyServlet extends Htt > > } else { > > writer.println("OK - Operation " + op + " without return value"); > > } > > - } catch( Exception ex ) { > > + } catch (Exception ex) { > > writer.println("Error - " + ex.toString()); > > ex.printStackTrace(writer); > > } > > @@ -217,9 +217,10 @@ public class JMXProxyServlet extends Htt > > > > /** > > * Parses parameter values from a parameter string. > > + * > > * @param paramString The string containing comma-separated > > - * operation-invocation parameters, or > > - * <code>null</code> if there are no parameters. > > + * operation-invocation parameters, or <code>null</code> if there > > + * are no parameters. > > * @return An array of String parameters (empty array if > > * <code>paramString</code> was <code>null</code>). > > */ > > @@ -230,46 +231,46 @@ public class JMXProxyServlet extends Htt > > return paramString.split(","); > > } > > > > + > > /** > > * Sets an MBean attribute's value. > > */ > > - private void setAttributeInternal(String onameStr, > > - String attributeName, > > - String value) > > - throws OperationsException, MBeanException, ReflectionException { > > - ObjectName oname=new ObjectName( onameStr ); > > - String type=registry.getType(oname, attributeName); > > - Object valueObj=registry.convertValue(type, value ); > > - mBeanServer.setAttribute( oname, new Attribute(attributeName, valueObj)); > > + private void setAttributeInternal(String onameStr, String attributeName, String value) > > + throws OperationsException, MBeanException, ReflectionException { > > + ObjectName oname = new ObjectName(onameStr); > > + String type = registry.getType(oname, attributeName); > > + Object valueObj = registry.convertValue(type, value); > > + mBeanServer.setAttribute(oname, new Attribute(attributeName, valueObj)); > > } > > > > + > > /** > > * Invokes an operation on an MBean. > > + * > > * @param onameStr The name of the MBean. > > * @param operation The name of the operation to invoke. > > * @param parameters An array of Strings containing the parameters to the > > - * operation. They will be converted to the appropriate > > - * types to call the reuested operation. > > + * operation. They will be converted to the appropriate types to > > + * call the reuested operation. > > * @return The value returned by the requested operation. > > */ > > - private Object invokeOperationInternal(String onameStr, > > - String operation, > > - String[] parameters) > > - throws OperationsException, MBeanException, ReflectionException { > > - ObjectName oname=new ObjectName( onameStr ); > > - MBeanOperationInfo methodInfo = registry.getMethodInfo(oname,operation); > > + private Object invokeOperationInternal(String onameStr, String operation, String[] parameters) > > + throws OperationsException, MBeanException, ReflectionException { > > + ObjectName oname = new ObjectName(onameStr); > > + MBeanOperationInfo methodInfo = registry.getMethodInfo(oname, operation); > > MBeanParameterInfo[] signature = methodInfo.getSignature(); > > String[] signatureTypes = new String[signature.length]; > > Object[] values = new Object[signature.length]; > > for (int i = 0; i < signature.length; i++) { > > - MBeanParameterInfo pi = signature[i]; > > - signatureTypes[i] = pi.getType(); > > - values[i] = registry.convertValue(pi.getType(), parameters[i] ); > > - } > > + MBeanParameterInfo pi = signature[i]; > > + signatureTypes[i] = pi.getType(); > > + values[i] = registry.convertValue(pi.getType(), parameters[i]); > > + } > > > > - return mBeanServer.invoke(oname,operation,values,signatureTypes); > > + return mBeanServer.invoke(oname, operation, values, signatureTypes); > > } > > > > + > > private void output(String indent, PrintWriter writer, Object result) { > > if (result instanceof Object[]) { > > for (Object obj : (Object[]) result) { > > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org > > For additional commands, e-mail: dev-h...@tomcat.apache.org > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org > For additional commands, e-mail: dev-h...@tomcat.apache.org >