logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mattsic...@apache.org
Subject svn commit: r1587392 - in /logging/log4j/log4j2/trunk: ./ log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/ log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/ log4j-core/src/main/java/org/apache/logging/log4j/...
Date Tue, 15 Apr 2014 03:03:16 GMT
Author: mattsicker
Date: Tue Apr 15 03:03:16 2014
New Revision: 1587392

URL: http://svn.apache.org/r1587392
Log:
Fix several compiler warnings about generics.

Modified:
    logging/log4j/log4j2/trunk/   (props changed)
    logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/OnStartupTriggeringPolicy.java
    logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/ResolverUtil.java
    logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/net/MulticastDNSAdvertiser.java
    logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/net/TLSSocketManager.java

Propchange: logging/log4j/log4j2/trunk/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Tue Apr 15 03:03:16 2014
@@ -5,3 +5,4 @@ target
 .classpath
 .settings
 .pmd
+classes

Modified: logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/OnStartupTriggeringPolicy.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/OnStartupTriggeringPolicy.java?rev=1587392&r1=1587391&r2=1587392&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/OnStartupTriggeringPolicy.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/OnStartupTriggeringPolicy.java
Tue Apr 15 03:03:16 2014
@@ -59,13 +59,15 @@ public class OnStartupTriggeringPolicy i
         // The reflection is necessary because without it, Google App Engine
         // will refuse to initialize this class.
         try {
+            // FIXME: Class.forName
             Class<?> factoryClass = Class.forName("java.lang.management.ManagementFactory");
-            Method getRuntimeMXBean = factoryClass.getMethod("getRuntimeMXBean", new Class[0]);
-            Object runtimeMXBean = getRuntimeMXBean.invoke(null, new Object[0]);
+            Method getRuntimeMXBean = factoryClass.getMethod("getRuntimeMXBean");
+            Object runtimeMXBean = getRuntimeMXBean.invoke(null);
             
+            // FIXME: Class.forName
             Class<?> runtimeMXBeanClass = Class.forName("java.lang.management.RuntimeMXBean");
-            Method getStartTime = runtimeMXBeanClass.getMethod("getStartTime", new Class[0]);
-            Long result = (Long) getStartTime.invoke(runtimeMXBean, new Object[0]);
+            Method getStartTime = runtimeMXBeanClass.getMethod("getStartTime");
+            Long result = (Long) getStartTime.invoke(runtimeMXBean);
             
             return result.longValue();
         } catch (Throwable t) {

Modified: logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/ResolverUtil.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/ResolverUtil.java?rev=1587392&r1=1587391&r2=1587392&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/ResolverUtil.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/ResolverUtil.java
Tue Apr 15 03:03:16 2014
@@ -307,7 +307,8 @@ public class ResolverUtil {
         @SuppressWarnings("RedundantCast")
         final BundleWiring wiring = (BundleWiring) FrameworkUtil.getBundle(
                 ResolverUtil.class).adapt(BundleWiring.class);
-        final Collection<String> list = wiring.listResources(packageName, "*.class",
+        @SuppressWarnings("unchecked")
+        final Collection<String> list = (Collection<String>) wiring.listResources(packageName,
"*.class",
             BundleWiring.LISTRESOURCES_RECURSE);
         for (final String name : list) {
             addIfMatching(test, name);

Modified: logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/net/MulticastDNSAdvertiser.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/net/MulticastDNSAdvertiser.java?rev=1587392&r1=1587391&r2=1587392&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/net/MulticastDNSAdvertiser.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/net/MulticastDNSAdvertiser.java
Tue Apr 15 03:03:16 2014
@@ -85,7 +85,7 @@ public class MulticastDNSAdvertiser impl
             boolean isVersion3 = false;
             try {
                 //create method is in version 3, not version 1
-                jmDNSClass.getMethod("create", (Class[])null);
+                jmDNSClass.getMethod("create");
                 isVersion3 = true;
             } catch (final NoSuchMethodException e) {
                 //no-op
@@ -98,7 +98,7 @@ public class MulticastDNSAdvertiser impl
             }
 
             try {
-                final Method method = jmDNSClass.getMethod("registerService", new Class[]{serviceInfoClass});
+                final Method method = jmDNSClass.getMethod("registerService", serviceInfoClass);
                 method.invoke(jmDNS, serviceInfo);
             } catch(final IllegalAccessException e) {
                 LOGGER.warn("Unable to invoke registerService method", e);
@@ -124,7 +124,7 @@ public class MulticastDNSAdvertiser impl
     public void unadvertise(final Object serviceInfo) {
         if (jmDNS != null) {
             try {
-                final Method method = jmDNSClass.getMethod("unregisterService", new Class[]{serviceInfoClass});
+                final Method method = jmDNSClass.getMethod("unregisterService", serviceInfoClass);
                 method.invoke(jmDNS, serviceInfo);
             } catch(final IllegalAccessException e) {
                 LOGGER.warn("Unable to invoke unregisterService method", e);
@@ -151,7 +151,7 @@ public class MulticastDNSAdvertiser impl
     private static Object createJmDNSVersion3()
     {
         try {
-            final Method jmDNSCreateMethod = jmDNSClass.getMethod("create", (Class[])null);
+            final Method jmDNSCreateMethod = jmDNSClass.getMethod("create");
             return jmDNSCreateMethod.invoke(null, (Object[])null);
         } catch (final IllegalAccessException e) {
             LOGGER.warn("Unable to invoke create method", e);
@@ -225,13 +225,14 @@ public class MulticastDNSAdvertiser impl
 
     private static Object initializeJMDNS() {
         try {
+            // FIXME: don't use Class.forName without a ClassLoader
             jmDNSClass = Class.forName("javax.jmdns.JmDNS");
             serviceInfoClass = Class.forName("javax.jmdns.ServiceInfo");
             //if version 3 is available, use it to constuct a serviceInfo instance, otherwise
support the version1 API
             boolean isVersion3 = false;
             try {
                 //create method is in version 3, not version 1
-                jmDNSClass.getMethod("create", (Class[])null);
+                jmDNSClass.getMethod("create");
                 isVersion3 = true;
             } catch (final NoSuchMethodException e) {
                 //no-op

Modified: logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/net/TLSSocketManager.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/net/TLSSocketManager.java?rev=1587392&r1=1587391&r2=1587392&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/net/TLSSocketManager.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/net/TLSSocketManager.java
Tue Apr 15 03:03:16 2014
@@ -19,6 +19,7 @@ package org.apache.logging.log4j.core.ne
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
+import java.io.Serializable;
 import java.net.InetAddress;
 import java.net.Socket;
 import java.net.UnknownHostException;
@@ -53,7 +54,7 @@ public class TLSSocketManager extends TC
      * @param layout        The Layout.
      */
     public TLSSocketManager(final String name, final OutputStream os, final Socket sock,
final SSLConfiguration sslConfig, final InetAddress addr,
-                            final String host, final int port, final int delay, final boolean
immediateFail, final Layout layout) {
+                            final String host, final int port, final int delay, final boolean
immediateFail, final Layout<? extends Serializable> layout) {
         super(name, os, sock, addr, host, port, delay, immediateFail, layout);
         this.sslConfig = sslConfig;
     }
@@ -64,10 +65,10 @@ public class TLSSocketManager extends TC
         private final int port;
         private final int delay;
         private final boolean immediateFail;
-        private final Layout layout;
+        private final Layout<? extends Serializable> layout;
 
         public TLSFactoryData(final SSLConfiguration sslConfig, final String host, final
int port, final int delay, final boolean immediateFail,
-                              final Layout layout) {
+                              final Layout<? extends Serializable> layout) {
             this.host = host;
             this.port = port;
             this.delay = delay;
@@ -78,7 +79,7 @@ public class TLSSocketManager extends TC
     }
 
     public static TLSSocketManager getSocketManager(final SSLConfiguration sslConfig, final
String host, int port,
-                                                    int delay, final boolean immediateFail,
final Layout layout ) {
+                                                    int delay, final boolean immediateFail,
final Layout<? extends Serializable> layout ) {
         if (Strings.isEmpty(host)) {
             throw new IllegalArgumentException("A host name is required");
         }
@@ -131,10 +132,11 @@ public class TLSSocketManager extends TC
                 checkDelay(data.delay, os);
             }
             catch (final IOException e) {
-                LOGGER.error("TLSSocketManager (" + name + ") " + e);
+                LOGGER.error("TLSSocketManager ({})", name, e);
                 os = new ByteArrayOutputStream();
             }
             catch (final TLSSocketManagerFactoryException e) {
+                LOGGER.catching(e);
                 return null;
             }
             return createManager(name, os, socket, data.sslConfig, address, data.host, data.port,
data.delay, data.immediateFail, data.layout);
@@ -146,7 +148,7 @@ public class TLSSocketManager extends TC
             try {
                 address = InetAddress.getByName(hostName);
             } catch (final UnknownHostException ex) {
-                LOGGER.error("Could not find address of " + hostName, ex);
+                LOGGER.error("Could not find address of {}", hostName, ex);
                 throw new TLSSocketManagerFactoryException();
             }
 
@@ -168,7 +170,7 @@ public class TLSSocketManager extends TC
             return socket;
         }
 
-        private TLSSocketManager createManager(final String name, final OutputStream os,
final Socket socket, final SSLConfiguration sslConfig, final InetAddress address, final String
host, final int port, final int delay, final boolean immediateFail, final Layout layout) {
+        private TLSSocketManager createManager(final String name, final OutputStream os,
final Socket socket, final SSLConfiguration sslConfig, final InetAddress address, final String
host, final int port, final int delay, final boolean immediateFail, final Layout<? extends
Serializable> layout) {
             return new TLSSocketManager(name, os, socket, sslConfig, address, host, port,
delay, immediateFail, layout);
         }
     }



Mime
View raw message