Return-Path: X-Original-To: apmail-logging-log4j-dev-archive@www.apache.org Delivered-To: apmail-logging-log4j-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5AB3D174E0 for ; Sun, 5 Oct 2014 00:24:24 +0000 (UTC) Received: (qmail 2120 invoked by uid 500); 5 Oct 2014 00:24:24 -0000 Delivered-To: apmail-logging-log4j-dev-archive@logging.apache.org Received: (qmail 2071 invoked by uid 500); 5 Oct 2014 00:24:24 -0000 Mailing-List: contact log4j-dev-help@logging.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Log4J Developers List" Reply-To: "Log4J Developers List" Delivered-To: mailing list log4j-dev@logging.apache.org Received: (qmail 2061 invoked by uid 99); 5 Oct 2014 00:24:24 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 05 Oct 2014 00:24:24 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of boards@gmail.com designates 209.85.214.175 as permitted sender) Received: from [209.85.214.175] (HELO mail-ob0-f175.google.com) (209.85.214.175) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 05 Oct 2014 00:23:58 +0000 Received: by mail-ob0-f175.google.com with SMTP id wn1so2468990obc.34 for ; Sat, 04 Oct 2014 17:23:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=KT2pQgI9I6HJSY53i/cxmBBIx1FXn+KpC9+pmMHL8Z8=; b=A/FtEvsf0gQYhCwDr0Kn+hBIMNQe/fvoW5QVfaXozVwQWPCTrXGpsMKQAuVwwniuZj JDSstc7p/RT0EKI+aIcr4jO8AxDQ9TqyWY24uihrPmVy5pzmjGGJ6HxsCU3xMR7jnFxI CWKXi2hXNAxglIbnlqln+ivX+q88VPMwO80kUBE/8HJvnes/5GsJq/Um1Vv1f92GrU8Y olxUjWCAtM5U9R7N9OXLTOvLyz5LgXBOo6UKw0iwQCJYQKSIPdmc5fNPme5PPnY2qRbD yDyo5VWy77l1397Ay8jZnc4v79qa4Ras13ZwNfWKkOG02pvO8n1XlUzIrIAAodMOcBlF WjRw== MIME-Version: 1.0 X-Received: by 10.182.43.201 with SMTP id y9mr16983228obl.34.1412468636774; Sat, 04 Oct 2014 17:23:56 -0700 (PDT) Received: by 10.76.84.39 with HTTP; Sat, 4 Oct 2014 17:23:56 -0700 (PDT) In-Reply-To: References: <96de46e5d71f4704b881b59ba26d274a@git.apache.org> Date: Sat, 4 Oct 2014 19:23:56 -0500 Message-ID: Subject: Re: [3/3] git commit: Add more type safety. From: Matt Sicker To: Log4J Developers List Content-Type: multipart/alternative; boundary=001a11c2d10a59f7fa0504a1fb6b X-Virus-Checked: Checked by ClamAV on apache.org --001a11c2d10a59f7fa0504a1fb6b Content-Type: text/plain; charset=UTF-8 My IDE settings must be messed up. Let me look into this. Thanks for noticing, though! On 4 October 2014 19:06, Gary Gregory 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: > 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 > Authored: Sat Oct 4 18:55:28 2014 -0500 > Committer: Matt Sicker > 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 paramMap = new HashMap 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 paramMap = new HashMap 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 > > JUnit in Action, Second Edition > Spring Batch in Action > Blog: http://garygregory.wordpress.com > Home: http://garygregory.com/ > Tweet! http://twitter.com/GaryGregory > -- Matt Sicker --001a11c2d10a59f7fa0504a1fb6b Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
My IDE settings must be messed up. Let me look into this. = Thanks for noticing, though!

On 4 October 2014 19:06, Gary Gregory &l= t;garydgregory@= gmail.com> wrote:
-1. This is backwards:

-import j= ava.awt.BorderLayout;
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.Font;
+import java.awt.*;

We do _not_ want * imports for norm= al imports, only for special cases like static imports of JUnit Assert meth= ods.

Gary

---------- Forwarded message ----------
From: <mattsicker@apache.org>
= Date: Sat, Oct 4, 2014 at 7:55 PM
Subject: [3/3] git commit: Add more ty= pe safety.
To: commits@logging.apache.org


Add more type safety.


Project: http://git-wip-us.apache.org/repos/asf/logging-log4j= 2/repo
Commit: http://git-wip-us.apache.org/repos/asf/log= ging-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

----------------------------------------------------------------------
=C2=A0.../apache/logging/log4j/jmx/gui/ClientGui.java | 22 +++++++++++-----= ----
=C2=A01 file changed, 12 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4= j2/blob/85f586c9/log4j-jmx-gui/src/main/java/org/apache/logging/log4j/jmx/g= ui/ClientGui.java
----------------------------------------------------------------------
diff --git a/log4j-jmx-gui/src/main/java/org/apache/logging/log4j/jmx/gui/C= lientGui.java b/log4j-jmx-gui/src/main/java/org/apache/logging/log4j/jmx/gu= i/ClientGui.java
index 0215fb5..b36cc67 100644
--- a/log4j-jmx-gui/src/main/java/org/apache/logging/log4j/jmx/gui/ClientGu= i.java
+++ b/log4j-jmx-gui/src/main/java/org/apache/logging/log4j/jmx/gui/ClientGu= i.java
@@ -16,17 +16,14 @@
=C2=A0 */
=C2=A0package 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.*;
=C2=A0import java.awt.event.ActionEvent;
=C2=A0import java.io.IOException;
=C2=A0import java.io.PrintWriter;
=C2=A0import java.io.StringWriter;
=C2=A0import java.util.HashMap;
=C2=A0import java.util.Map;
-
+import java.util.Properties;
=C2=A0import javax.management.InstanceNotFoundException;
=C2=A0import javax.management.JMException;
=C2=A0import javax.management.ListenerNotFoundException;
@@ -177,7 +174,12 @@ public class ClientGui extends JPanel implements Notif= icationListener {

=C2=A0 =C2=A0 =C2=A0private void handleNotificationInAwtEventThread(final N= otification notif, final Object paramObject) {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (StatusLoggerAdminMBean.NOTIF_TYPE_MES= SAGE.equals(notif.getType())) {
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 final JTextArea text =3D statusL= ogTextAreaMap.get(paramObject);
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (!(paramObject instanceof Obj= ectName)) {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 handle("Inval= id notification object type", new ClassCastException(paramObject.getCl= ass().getName()));
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 }
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 final ObjectName param =3D (Obje= ctName) paramObject;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 final JTextArea text =3D statusL= ogTextAreaMap.get(param);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (text !=3D null) {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0text.append(n= otif.getMessage() + '\n');
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
@@ -258,10 +260,10 @@ public class ClientGui extends JPanel implements Noti= ficationListener {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0serviceUrl =3D "servic= e:jmx:rmi:///jndi/rmi://" + args[0] + "/jmxrmi";
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0final JMXServiceURL url =3D new JMXServic= eURL(serviceUrl);
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 final Map<String, String> paramMap =3D n= ew HashMap<String, String>();
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 for (final Object objKey : System.getPropertie= s().keySet()) {
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 final String key =3D (String) ob= jKey;
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 paramMap.put(key, System.getProp= erties().getProperty(key));
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 final Properties props =3D System.getPropertie= s();
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 final Map<String, String> paramMap =3D n= ew HashMap<String, String>(props.size());
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 for (final String key : props.stringPropertyNa= mes()) {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 paramMap.put(key, props.getPrope= rty(key));
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0final JMXConnector connector =3D JMXConne= ctorFactory.connect(url, paramMap);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0final Client client =3D new Client(connec= tor);




--



--
Matt Sicker = <boards@gmail.com<= /a>>
--001a11c2d10a59f7fa0504a1fb6b--