From commits-return-1878-apmail-logging-commits-archive=logging.apache.org@logging.apache.org Fri Jan 11 05:30:58 2013 Return-Path: X-Original-To: apmail-logging-commits-archive@minotaur.apache.org Delivered-To: apmail-logging-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id DA9CFE9D2 for ; Fri, 11 Jan 2013 05:30:58 +0000 (UTC) Received: (qmail 4016 invoked by uid 500); 11 Jan 2013 05:30:58 -0000 Delivered-To: apmail-logging-commits-archive@logging.apache.org Received: (qmail 3972 invoked by uid 500); 11 Jan 2013 05:30:57 -0000 Mailing-List: contact commits-help@logging.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@logging.apache.org Delivered-To: mailing list commits@logging.apache.org Received: (qmail 3947 invoked by uid 99); 11 Jan 2013 05:30:56 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 11 Jan 2013 05:30:56 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 11 Jan 2013 05:30:52 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 6AB9823888D2; Fri, 11 Jan 2013 05:30:31 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1431895 - in /logging/log4j/log4j2/trunk: core/src/test/java/org/apache/logging/log4j/core/pattern/ samples/flume-common/src/main/java/org/apache/logging/log4j/samples/app/ samples/flume-common/src/main/java/org/apache/logging/log4j/sample... Date: Fri, 11 Jan 2013 05:30:31 -0000 To: commits@logging.apache.org From: ggregory@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130111053031.6AB9823888D2@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: ggregory Date: Fri Jan 11 05:30:30 2013 New Revision: 1431895 URL: http://svn.apache.org/viewvc?rev=1431895&view=rev Log: Add final modifier to local variables. Modified: logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/pattern/MessagePatternConverterTest.java logging/log4j/log4j2/trunk/samples/flume-common/src/main/java/org/apache/logging/log4j/samples/app/LogEventFactory.java logging/log4j/log4j2/trunk/samples/flume-common/src/main/java/org/apache/logging/log4j/samples/app/LoggingController.java logging/log4j/log4j2/trunk/samples/flume-common/src/main/java/org/apache/logging/log4j/samples/app/MockEventsSupplier.java logging/log4j/log4j2/trunk/samples/flume-common/src/main/java/org/apache/logging/log4j/samples/util/NamingUtils.java logging/log4j/log4j2/trunk/web/src/main/java/org/apache/logging/log4j/core/web/JNDIContextFilter.java logging/log4j/log4j2/trunk/web/src/main/java/org/apache/logging/log4j/core/web/Log4jContextListener.java logging/log4j/log4j2/trunk/web/src/test/java/org/apache/logging/log4j/core/web/Log4jContextListenerTest.java Modified: logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/pattern/MessagePatternConverterTest.java URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/pattern/MessagePatternConverterTest.java?rev=1431895&r1=1431894&r2=1431895&view=diff ============================================================================== --- logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/pattern/MessagePatternConverterTest.java (original) +++ logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/pattern/MessagePatternConverterTest.java Fri Jan 11 05:30:30 2013 @@ -34,7 +34,7 @@ public class MessagePatternConverterTest @Test public void testPattern() throws Exception { - MessagePatternConverter converter = MessagePatternConverter.newInstance(null, null); + final MessagePatternConverter converter = MessagePatternConverter.newInstance(null, null); Message msg = new SimpleMessage("Hello!"); LogEvent event = new Log4jLogEvent("MyLogger", null, null, Level.DEBUG, msg, null); StringBuilder sb = new StringBuilder(); @@ -54,8 +54,8 @@ public class MessagePatternConverterTest @Test public void testPatternWithConfiguration() throws Exception { - Configuration config = new DefaultConfiguration(); - MessagePatternConverter converter = MessagePatternConverter.newInstance(config, null); + final Configuration config = new DefaultConfiguration(); + final MessagePatternConverter converter = MessagePatternConverter.newInstance(config, null); Message msg = new SimpleMessage("Hello!"); LogEvent event = new Log4jLogEvent("MyLogger", null, null, Level.DEBUG, msg, null); StringBuilder sb = new StringBuilder(); Modified: logging/log4j/log4j2/trunk/samples/flume-common/src/main/java/org/apache/logging/log4j/samples/app/LogEventFactory.java URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/samples/flume-common/src/main/java/org/apache/logging/log4j/samples/app/LogEventFactory.java?rev=1431895&r1=1431894&r2=1431895&view=diff ============================================================================== --- logging/log4j/log4j2/trunk/samples/flume-common/src/main/java/org/apache/logging/log4j/samples/app/LogEventFactory.java (original) +++ logging/log4j/log4j2/trunk/samples/flume-common/src/main/java/org/apache/logging/log4j/samples/app/LogEventFactory.java Fri Jan 11 05:30:30 2013 @@ -34,11 +34,11 @@ public class LogEventFactory { public static T getEvent(Class intrface) { - Class[] interfaces = new Class[]{intrface}; + final Class[] interfaces = new Class[]{intrface}; - String eventId = NamingUtils.lowerFirst(intrface.getSimpleName()); - StructuredDataMessage msg = new StructuredDataMessage(eventId, null, "Audit"); - AuditEvent audit = (AuditEvent) Proxy.newProxyInstance(intrface + final String eventId = NamingUtils.lowerFirst(intrface.getSimpleName()); + final StructuredDataMessage msg = new StructuredDataMessage(eventId, null, "Audit"); + final AuditEvent audit = (AuditEvent) Proxy.newProxyInstance(intrface .getClassLoader(), interfaces, new AuditProxy(msg, intrface)); return (T) audit; @@ -58,17 +58,17 @@ public class LogEventFactory { throws Throwable { if (method.getName().equals("logEvent")) { - StringBuilder missing = new StringBuilder(); + final StringBuilder missing = new StringBuilder(); - Method[] methods = intrface.getMethods(); + final Method[] methods = intrface.getMethods(); - for (Method _method : methods) { - String name = NamingUtils.lowerFirst(NamingUtils + for (final Method _method : methods) { + final String name = NamingUtils.lowerFirst(NamingUtils .getMethodShortName(_method.getName())); - Annotation[] annotations = _method.getDeclaredAnnotations(); - for (Annotation annotation : annotations) { - Constraint constraint = (Constraint) annotation; + final Annotation[] annotations = _method.getDeclaredAnnotations(); + for (final Annotation annotation : annotations) { + final Constraint constraint = (Constraint) annotation; if (constraint.required() && msg.get(name) == null) { if (missing.length() > 0) { @@ -86,11 +86,11 @@ public class LogEventFactory { EventLogger.logEvent(msg); } if (method.getName().equals("setCompletionStatus")) { - String name = NamingUtils.lowerFirst(NamingUtils.getMethodShortName(method.getName())); + final String name = NamingUtils.lowerFirst(NamingUtils.getMethodShortName(method.getName())); msg.put(name, objects[0].toString()); } if (method.getName().startsWith("set")) { - String name = NamingUtils.lowerFirst(NamingUtils.getMethodShortName(method.getName())); + final String name = NamingUtils.lowerFirst(NamingUtils.getMethodShortName(method.getName())); /* * Perform any validation here. Currently the catalog doesn't Modified: logging/log4j/log4j2/trunk/samples/flume-common/src/main/java/org/apache/logging/log4j/samples/app/LoggingController.java URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/samples/flume-common/src/main/java/org/apache/logging/log4j/samples/app/LoggingController.java?rev=1431895&r1=1431894&r2=1431895&view=diff ============================================================================== --- logging/log4j/log4j2/trunk/samples/flume-common/src/main/java/org/apache/logging/log4j/samples/app/LoggingController.java (original) +++ logging/log4j/log4j2/trunk/samples/flume-common/src/main/java/org/apache/logging/log4j/samples/app/LoggingController.java Fri Jan 11 05:30:30 2013 @@ -81,19 +81,19 @@ public class LoggingController { public void run() { while (generateLog) { // Generate rand number between 1 to 10 - int rand = ran.nextInt(9) + 1; + final int rand = ran.nextInt(9) + 1; // Sleep for rand seconds try { Thread.sleep(rand * 1000); - } catch (InterruptedException e) { + } catch (final InterruptedException e) { logger.warn("WARN", e); } // Write rand number of logs for (int i = 0; i < rand; i++) { - int eventIndex = (Math.abs(ran.nextInt())) % events.size(); - AuditEvent event = events.get(eventIndex); + final int eventIndex = (Math.abs(ran.nextInt())) % events.size(); + final AuditEvent event = events.get(eventIndex); RequestContext.setUserId(member); event.logEvent(); Modified: logging/log4j/log4j2/trunk/samples/flume-common/src/main/java/org/apache/logging/log4j/samples/app/MockEventsSupplier.java URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/samples/flume-common/src/main/java/org/apache/logging/log4j/samples/app/MockEventsSupplier.java?rev=1431895&r1=1431894&r2=1431895&view=diff ============================================================================== --- logging/log4j/log4j2/trunk/samples/flume-common/src/main/java/org/apache/logging/log4j/samples/app/MockEventsSupplier.java (original) +++ logging/log4j/log4j2/trunk/samples/flume-common/src/main/java/org/apache/logging/log4j/samples/app/MockEventsSupplier.java Fri Jan 11 05:30:30 2013 @@ -34,20 +34,20 @@ public class MockEventsSupplier { public static List getAllEvents(String member) { - List events = new ArrayList(); + final List events = new ArrayList(); - Login login = LogEventFactory.getEvent(Login.class); + final Login login = LogEventFactory.getEvent(Login.class); login.setStartPageOption("account summary"); login.setSource("online"); login.setMember(member); events.add(login); - ChangePassword changePassword = LogEventFactory.getEvent(ChangePassword.class); + final ChangePassword changePassword = LogEventFactory.getEvent(ChangePassword.class); changePassword.setMember(member); events.add(changePassword); - Transfer transfer = LogEventFactory.getEvent(Transfer.class); + final Transfer transfer = LogEventFactory.getEvent(Transfer.class); transfer.setAmount("4251"); transfer.setFromAccount("REPLACE"); // getAccount(mbr, accounts)); @@ -62,7 +62,7 @@ public class MockEventsSupplier { transfer.setMember(member); events.add(transfer); - Alert alert = LogEventFactory.getEvent(Alert.class); + final Alert alert = LogEventFactory.getEvent(Alert.class); alert.setAction("add"); alert.setType("balance alert"); @@ -72,7 +72,7 @@ public class MockEventsSupplier { alert.setMember(member); events.add(alert); - ScheduledTransaction scheduledTransaction = LogEventFactory + final ScheduledTransaction scheduledTransaction = LogEventFactory .getEvent(ScheduledTransaction.class); scheduledTransaction.setAction("add"); Modified: logging/log4j/log4j2/trunk/samples/flume-common/src/main/java/org/apache/logging/log4j/samples/util/NamingUtils.java URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/samples/flume-common/src/main/java/org/apache/logging/log4j/samples/util/NamingUtils.java?rev=1431895&r1=1431894&r2=1431895&view=diff ============================================================================== --- logging/log4j/log4j2/trunk/samples/flume-common/src/main/java/org/apache/logging/log4j/samples/util/NamingUtils.java (original) +++ logging/log4j/log4j2/trunk/samples/flume-common/src/main/java/org/apache/logging/log4j/samples/util/NamingUtils.java Fri Jan 11 05:30:30 2013 @@ -51,7 +51,7 @@ public class NamingUtils { } public static void main(String[] args) { - String blah = "com.test.generator.Classname"; + final String blah = "com.test.generator.Classname"; System.out.println(getSimpleName(blah)); System.out.println(lowerFirst(getSimpleName(blah))); Modified: logging/log4j/log4j2/trunk/web/src/main/java/org/apache/logging/log4j/core/web/JNDIContextFilter.java URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/web/src/main/java/org/apache/logging/log4j/core/web/JNDIContextFilter.java?rev=1431895&r1=1431894&r2=1431895&view=diff ============================================================================== --- logging/log4j/log4j2/trunk/web/src/main/java/org/apache/logging/log4j/core/web/JNDIContextFilter.java (original) +++ logging/log4j/log4j2/trunk/web/src/main/java/org/apache/logging/log4j/core/web/JNDIContextFilter.java Fri Jan 11 05:30:30 2013 @@ -54,15 +54,15 @@ public class JNDIContextFilter implement public void init(FilterConfig filterConfig) throws ServletException { context = filterConfig.getServletContext(); name = filterConfig.getInitParameter(CONTEXT_NAME); - String configLocn = filterConfig.getInitParameter(CONFIG_LOCATION); + final String configLocn = filterConfig.getInitParameter(CONFIG_LOCATION); if (name == null) { throw new UnavailableException("A context-name attribute is required"); } if (context.getAttribute(Log4jContextListener.LOG4J_CONTEXT_ATTRIBUTE) == null) { LoggerContext ctx; - LoggerContextFactory factory = LogManager.getFactory(); + final LoggerContextFactory factory = LogManager.getFactory(); if (factory instanceof Log4jContextFactory) { - ContextSelector sel = ((Log4jContextFactory) factory).getSelector(); + final ContextSelector sel = ((Log4jContextFactory) factory).getSelector(); if (sel instanceof NamedContextSelector) { selector = (NamedContextSelector) sel; ctx = selector.locateContext(name, configLocn); @@ -80,7 +80,7 @@ public class JNDIContextFilter implement public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { - LoggerContext ctx = (LoggerContext) context.getAttribute(Log4jContextListener.LOG4J_CONTEXT_ATTRIBUTE); + final LoggerContext ctx = (LoggerContext) context.getAttribute(Log4jContextListener.LOG4J_CONTEXT_ATTRIBUTE); if (ctx != null) { ContextAnchor.THREAD_CONTEXT.set(ctx); try { @@ -94,7 +94,7 @@ public class JNDIContextFilter implement } public void destroy() { - LoggerContext ctx = (LoggerContext) context.getAttribute(Log4jContextListener.LOG4J_CONTEXT_ATTRIBUTE); + final LoggerContext ctx = (LoggerContext) context.getAttribute(Log4jContextListener.LOG4J_CONTEXT_ATTRIBUTE); if (ctx != null && created) { context.log("Removing context for " + name); context.removeAttribute(Log4jContextListener.LOG4J_CONTEXT_ATTRIBUTE); Modified: logging/log4j/log4j2/trunk/web/src/main/java/org/apache/logging/log4j/core/web/Log4jContextListener.java URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/web/src/main/java/org/apache/logging/log4j/core/web/Log4jContextListener.java?rev=1431895&r1=1431894&r2=1431895&view=diff ============================================================================== --- logging/log4j/log4j2/trunk/web/src/main/java/org/apache/logging/log4j/core/web/Log4jContextListener.java (original) +++ logging/log4j/log4j2/trunk/web/src/main/java/org/apache/logging/log4j/core/web/Log4jContextListener.java Fri Jan 11 05:30:30 2013 @@ -49,8 +49,8 @@ public class Log4jContextListener implem * @param event The ServletContextEvent. */ public void contextInitialized(ServletContextEvent event) { - ServletContext context = event.getServletContext(); - String locn = context.getInitParameter(LOG4J_CONFIG); + final ServletContext context = event.getServletContext(); + final String locn = context.getInitParameter(LOG4J_CONFIG); String name = context.getInitParameter(LOG4J_CONTEXT_NAME); if (name == null) { name = context.getServletContextName(); @@ -67,14 +67,14 @@ public class Log4jContextListener implem * @param event The ServletContextEvent. */ public void contextDestroyed(ServletContextEvent event) { - LoggerContext ctx = (LoggerContext) event.getServletContext().getAttribute(LOG4J_CONTEXT_ATTRIBUTE); + final LoggerContext ctx = (LoggerContext) event.getServletContext().getAttribute(LOG4J_CONTEXT_ATTRIBUTE); Configurator.shutdown(ctx); } private ClassLoader getClassLoader(ServletContext context) { - Method[] methods = context.getClass().getMethods(); + final Method[] methods = context.getClass().getMethods(); Method getClassLoader = null; - for (Method method : methods) { + for (final Method method : methods) { if (method.getName().equals("getClassLoader")) { getClassLoader = method; break; @@ -84,7 +84,7 @@ public class Log4jContextListener implem if (getClassLoader != null) { try { return (ClassLoader) getClassLoader.invoke(context, null); - } catch (Exception ex) { + } catch (final Exception ex) { // Ignore the exception } } Modified: logging/log4j/log4j2/trunk/web/src/test/java/org/apache/logging/log4j/core/web/Log4jContextListenerTest.java URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/web/src/test/java/org/apache/logging/log4j/core/web/Log4jContextListenerTest.java?rev=1431895&r1=1431894&r2=1431895&view=diff ============================================================================== --- logging/log4j/log4j2/trunk/web/src/test/java/org/apache/logging/log4j/core/web/Log4jContextListenerTest.java (original) +++ logging/log4j/log4j2/trunk/web/src/test/java/org/apache/logging/log4j/core/web/Log4jContextListenerTest.java Fri Jan 11 05:30:30 2013 @@ -50,19 +50,19 @@ public class Log4jContextListenerTest { @Test public void testFromFile() throws Exception { - MockServletContext context = new MockServletContext(); + final MockServletContext context = new MockServletContext(); context.setInitParameter(Log4jContextListener.LOG4J_CONTEXT_NAME, "Test1"); context.setInitParameter(Log4jContextListener.LOG4J_CONFIG, "target/test-classes/log4j2-config.xml"); - Log4jContextListener listener = new Log4jContextListener(); - ServletContextEvent event = new ServletContextEvent(context); + final Log4jContextListener listener = new Log4jContextListener(); + final ServletContextEvent event = new ServletContextEvent(context); listener.contextInitialized(event); - Logger logger = LogManager.getLogger("org.apache.test.TestConfigurator"); - LoggerContext ctx = (LoggerContext) LogManager.getContext(false); + final Logger logger = LogManager.getLogger("org.apache.test.TestConfigurator"); + final LoggerContext ctx = (LoggerContext) LogManager.getContext(false); Configuration config = ctx.getConfiguration(); assertNotNull("No configuration", config); assertTrue("Incorrect Configuration. Expected " + CONFIG_NAME + " but found " + config.getName(), CONFIG_NAME.equals(config.getName())); - Map map = config.getAppenders(); + final Map map = config.getAppenders(); assertNotNull("No Appenders", map != null && map.size() > 0); assertTrue("Wrong configuration", map.containsKey("List")); listener.contextDestroyed(event); @@ -73,19 +73,19 @@ public class Log4jContextListenerTest { @Test public void testFromClassPath() throws Exception { - MockServletContext context = new MockServletContext(); + final MockServletContext context = new MockServletContext(); context.setInitParameter(Log4jContextListener.LOG4J_CONTEXT_NAME, "Test1"); context.setInitParameter(Log4jContextListener.LOG4J_CONFIG, "log4j2-config.xml"); - Log4jContextListener listener = new Log4jContextListener(); - ServletContextEvent event = new ServletContextEvent(context); + final Log4jContextListener listener = new Log4jContextListener(); + final ServletContextEvent event = new ServletContextEvent(context); listener.contextInitialized(event); - Logger logger = LogManager.getLogger("org.apache.test.TestConfigurator"); - LoggerContext ctx = (LoggerContext) LogManager.getContext(false); + final Logger logger = LogManager.getLogger("org.apache.test.TestConfigurator"); + final LoggerContext ctx = (LoggerContext) LogManager.getContext(false); Configuration config = ctx.getConfiguration(); assertNotNull("No configuration", config); assertTrue("Incorrect Configuration. Expected " + CONFIG_NAME + " but found " + config.getName(), CONFIG_NAME.equals(config.getName())); - Map map = config.getAppenders(); + final Map map = config.getAppenders(); assertNotNull("No Appenders", map != null && map.size() > 0); assertTrue("Wrong configuration", map.containsKey("List")); listener.contextDestroyed(event); @@ -96,18 +96,18 @@ public class Log4jContextListenerTest { @Test public void testByName() throws Exception { - MockServletContext context = new MockServletContext(); + final MockServletContext context = new MockServletContext(); context.setInitParameter(Log4jContextListener.LOG4J_CONTEXT_NAME, "-config"); - Log4jContextListener listener = new Log4jContextListener(); - ServletContextEvent event = new ServletContextEvent(context); + final Log4jContextListener listener = new Log4jContextListener(); + final ServletContextEvent event = new ServletContextEvent(context); listener.contextInitialized(event); - Logger logger = LogManager.getLogger("org.apache.test.TestConfigurator"); - LoggerContext ctx = (LoggerContext) LogManager.getContext(false); + final Logger logger = LogManager.getLogger("org.apache.test.TestConfigurator"); + final LoggerContext ctx = (LoggerContext) LogManager.getContext(false); Configuration config = ctx.getConfiguration(); assertNotNull("No configuration", config); assertTrue("Incorrect Configuration. Expected " + CONFIG_NAME + " but found " + config.getName(), CONFIG_NAME.equals(config.getName())); - Map map = config.getAppenders(); + final Map map = config.getAppenders(); assertNotNull("No Appenders", map != null && map.size() > 0); assertTrue("Wrong configuration", map.containsKey("List")); listener.contextDestroyed(event);