logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Sicker <boa...@gmail.com>
Subject Re: [3/3] git commit: Add more type safety.
Date Sun, 05 Oct 2014 00:23:56 GMT
My IDE settings must be messed up. Let me look into this. Thanks for
noticing, though!

On 4 October 2014 19:06, Gary Gregory <garydgregory@gmail.com> wrote:

> -1. This is backwards:
>
> -import java.awt.BorderLayout;
> -import java.awt.Color;
> -import java.awt.Component;
> -import java.awt.Font;
> +import java.awt.*;
>
> We do _not_ want * imports for normal imports, only for special cases like
> static imports of JUnit Assert methods.
>
> Gary
>
> ---------- Forwarded message ----------
> From: <mattsicker@apache.org>
> Date: Sat, Oct 4, 2014 at 7:55 PM
> Subject: [3/3] git commit: Add more type safety.
> To: commits@logging.apache.org
>
>
> Add more type safety.
>
>
> Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
> Commit:
> http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/85f586c9
> Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/85f586c9
> Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/85f586c9
>
> Branch: refs/heads/master
> Commit: 85f586c99514cf5bc73586d2d078fe0237581ad7
> Parents: 16045e6
> Author: Matt Sicker <mattsicker@apache.org>
> Authored: Sat Oct 4 18:55:28 2014 -0500
> Committer: Matt Sicker <mattsicker@apache.org>
> Committed: Sat Oct 4 18:55:28 2014 -0500
>
> ----------------------------------------------------------------------
>  .../apache/logging/log4j/jmx/gui/ClientGui.java | 22 +++++++++++---------
>  1 file changed, 12 insertions(+), 10 deletions(-)
> ----------------------------------------------------------------------
>
>
>
> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/85f586c9/log4j-jmx-gui/src/main/java/org/apache/logging/log4j/jmx/gui/ClientGui.java
> ----------------------------------------------------------------------
> diff --git
> a/log4j-jmx-gui/src/main/java/org/apache/logging/log4j/jmx/gui/ClientGui.java
> b/log4j-jmx-gui/src/main/java/org/apache/logging/log4j/jmx/gui/ClientGui.java
> index 0215fb5..b36cc67 100644
> ---
> a/log4j-jmx-gui/src/main/java/org/apache/logging/log4j/jmx/gui/ClientGui.java
> +++
> b/log4j-jmx-gui/src/main/java/org/apache/logging/log4j/jmx/gui/ClientGui.java
> @@ -16,17 +16,14 @@
>   */
>  package org.apache.logging.log4j.jmx.gui;
>
> -import java.awt.BorderLayout;
> -import java.awt.Color;
> -import java.awt.Component;
> -import java.awt.Font;
> +import java.awt.*;
>  import java.awt.event.ActionEvent;
>  import java.io.IOException;
>  import java.io.PrintWriter;
>  import java.io.StringWriter;
>  import java.util.HashMap;
>  import java.util.Map;
> -
> +import java.util.Properties;
>  import javax.management.InstanceNotFoundException;
>  import javax.management.JMException;
>  import javax.management.ListenerNotFoundException;
> @@ -177,7 +174,12 @@ public class ClientGui extends JPanel implements
> NotificationListener {
>
>      private void handleNotificationInAwtEventThread(final Notification
> notif, final Object paramObject) {
>          if
> (StatusLoggerAdminMBean.NOTIF_TYPE_MESSAGE.equals(notif.getType())) {
> -            final JTextArea text = statusLogTextAreaMap.get(paramObject);
> +            if (!(paramObject instanceof ObjectName)) {
> +                handle("Invalid notification object type", new
> ClassCastException(paramObject.getClass().getName()));
> +                return;
> +            }
> +            final ObjectName param = (ObjectName) paramObject;
> +            final JTextArea text = statusLogTextAreaMap.get(param);
>              if (text != null) {
>                  text.append(notif.getMessage() + '\n');
>              }
> @@ -258,10 +260,10 @@ public class ClientGui extends JPanel implements
> NotificationListener {
>              serviceUrl = "service:jmx:rmi:///jndi/rmi://" + args[0] +
> "/jmxrmi";
>          }
>          final JMXServiceURL url = new JMXServiceURL(serviceUrl);
> -        final Map<String, String> paramMap = new HashMap<String,
> String>();
> -        for (final Object objKey : System.getProperties().keySet()) {
> -            final String key = (String) objKey;
> -            paramMap.put(key, System.getProperties().getProperty(key));
> +        final Properties props = System.getProperties();
> +        final Map<String, String> paramMap = new HashMap<String,
> String>(props.size());
> +        for (final String key : props.stringPropertyNames()) {
> +            paramMap.put(key, props.getProperty(key));
>          }
>          final JMXConnector connector = JMXConnectorFactory.connect(url,
> paramMap);
>          final Client client = new Client(connector);
>
>
>
>
> --
> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> Java Persistence with Hibernate, Second Edition
> <http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory
>



-- 
Matt Sicker <boards@gmail.com>

Mime
View raw message