From b9b23c9b44774209913686749cbda83631dbb9cd Mon Sep 17 00:00:00 2001 From: James Perkins Date: Mon, 10 Dec 2018 14:27:54 -0800 Subject: [PATCH] [LOGMGR-234] Remove the NullHandler and FlushableClosable. --- .../java/org/jboss/logmanager/ExtHandler.java | 4 +-- .../handlers/FlushableCloseable.java | 28 ------------------- .../logmanager/handlers/NullHandler.java | 28 ------------------- .../org/jboss/logmanager/HandlerTests.java | 3 +- .../ext/handlers/SslTcpOutputStream.java | 5 ++-- .../ext/handlers/TcpOutputStream.java | 5 ++-- .../ext/handlers/UdpOutputStream.java | 5 ++-- 7 files changed, 9 insertions(+), 69 deletions(-) delete mode 100644 core/src/main/java/org/jboss/logmanager/handlers/FlushableCloseable.java delete mode 100644 core/src/main/java/org/jboss/logmanager/handlers/NullHandler.java diff --git a/core/src/main/java/org/jboss/logmanager/ExtHandler.java b/core/src/main/java/org/jboss/logmanager/ExtHandler.java index 58f69937..20806c43 100644 --- a/core/src/main/java/org/jboss/logmanager/ExtHandler.java +++ b/core/src/main/java/org/jboss/logmanager/ExtHandler.java @@ -19,6 +19,7 @@ package org.jboss.logmanager; +import java.io.Flushable; import java.io.UnsupportedEncodingException; import java.security.Permission; import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; @@ -31,13 +32,12 @@ import java.util.logging.LoggingPermission; import org.jboss.logmanager.errormanager.OnlyOnceErrorManager; -import org.jboss.logmanager.handlers.FlushableCloseable; /** * An extended logger handler. Use this class as a base class for log handlers which require {@code ExtLogRecord} * instances. */ -public abstract class ExtHandler extends Handler implements FlushableCloseable { +public abstract class ExtHandler extends Handler implements AutoCloseable, Flushable { private static final Permission CONTROL_PERMISSION = new LoggingPermission("control", null); private volatile boolean autoFlush = true; diff --git a/core/src/main/java/org/jboss/logmanager/handlers/FlushableCloseable.java b/core/src/main/java/org/jboss/logmanager/handlers/FlushableCloseable.java deleted file mode 100644 index cf911afb..00000000 --- a/core/src/main/java/org/jboss/logmanager/handlers/FlushableCloseable.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * JBoss, Home of Professional Open Source. - * - * Copyright 2014 Red Hat, Inc., and individual contributors - * as indicated by the @author tags. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jboss.logmanager.handlers; - -import java.io.Flushable; -import java.io.Closeable; - -/** - * A resource which is flushable and closeable. - */ -public interface FlushableCloseable extends Flushable, Closeable {} diff --git a/core/src/main/java/org/jboss/logmanager/handlers/NullHandler.java b/core/src/main/java/org/jboss/logmanager/handlers/NullHandler.java deleted file mode 100644 index 2c741115..00000000 --- a/core/src/main/java/org/jboss/logmanager/handlers/NullHandler.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * JBoss, Home of Professional Open Source. - * - * Copyright 2014 Red Hat, Inc., and individual contributors - * as indicated by the @author tags. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jboss.logmanager.handlers; - -import org.jboss.logmanager.ExtHandler; - -/** - * A handler which performs no action other than to run any attached filter. - */ -public final class NullHandler extends ExtHandler { -} diff --git a/core/src/test/java/org/jboss/logmanager/HandlerTests.java b/core/src/test/java/org/jboss/logmanager/HandlerTests.java index db8a19a3..541e9daa 100644 --- a/core/src/test/java/org/jboss/logmanager/HandlerTests.java +++ b/core/src/test/java/org/jboss/logmanager/HandlerTests.java @@ -23,7 +23,6 @@ import static org.junit.Assert.*; import org.jboss.logmanager.handlers.WriterHandler; import org.jboss.logmanager.handlers.OutputStreamHandler; -import org.jboss.logmanager.handlers.NullHandler; import org.jboss.logmanager.handlers.FileHandler; import org.jboss.logmanager.formatters.PatternFormatter; @@ -43,7 +42,7 @@ public final class HandlerTests { @Test public void testNullHandler() throws Throwable { - final NullHandler handler = new NullHandler(); + final ExtHandler handler = new ExtHandler(){}; handler.setLevel(Level.ALL); handler.publish(new ExtLogRecord(Level.INFO, "Test message", null)); } diff --git a/ext/src/main/java/org/jboss/logmanager/ext/handlers/SslTcpOutputStream.java b/ext/src/main/java/org/jboss/logmanager/ext/handlers/SslTcpOutputStream.java index 85b7f5f9..b4933c11 100644 --- a/ext/src/main/java/org/jboss/logmanager/ext/handlers/SslTcpOutputStream.java +++ b/ext/src/main/java/org/jboss/logmanager/ext/handlers/SslTcpOutputStream.java @@ -19,13 +19,12 @@ package org.jboss.logmanager.ext.handlers; +import java.io.Flushable; import java.io.IOException; import java.net.InetAddress; import javax.net.SocketFactory; import javax.net.ssl.SSLSocketFactory; -import org.jboss.logmanager.handlers.FlushableCloseable; - /** * An output stream that writes data to a {@link java.net.Socket socket}. Uses {@link * SSLSocketFactory#getDefault()} to create the socket. @@ -33,7 +32,7 @@ * @author James R. Perkins */ @SuppressWarnings({"unused", "WeakerAccess"}) -public class SslTcpOutputStream extends TcpOutputStream implements FlushableCloseable { +public class SslTcpOutputStream extends TcpOutputStream implements AutoCloseable, Flushable { /** * Creates a SSL TCP output stream. diff --git a/ext/src/main/java/org/jboss/logmanager/ext/handlers/TcpOutputStream.java b/ext/src/main/java/org/jboss/logmanager/ext/handlers/TcpOutputStream.java index 2d428eb2..15a6336f 100644 --- a/ext/src/main/java/org/jboss/logmanager/ext/handlers/TcpOutputStream.java +++ b/ext/src/main/java/org/jboss/logmanager/ext/handlers/TcpOutputStream.java @@ -20,6 +20,7 @@ package org.jboss.logmanager.ext.handlers; import java.io.Closeable; +import java.io.Flushable; import java.io.IOException; import java.io.OutputStream; import java.net.InetAddress; @@ -34,8 +35,6 @@ import java.util.concurrent.TimeUnit; import javax.net.SocketFactory; -import org.jboss.logmanager.handlers.FlushableCloseable; - /** * An output stream that writes data to a {@link Socket socket}. *

@@ -49,7 +48,7 @@ * @author James R. Perkins */ @SuppressWarnings({"unused", "WeakerAccess"}) -public class TcpOutputStream extends OutputStream implements FlushableCloseable { +public class TcpOutputStream extends OutputStream implements AutoCloseable, Flushable { private static final long retryTimeout = 5L; private static final long maxRetryTimeout = 40L; private static final int maxErrors = 10; diff --git a/ext/src/main/java/org/jboss/logmanager/ext/handlers/UdpOutputStream.java b/ext/src/main/java/org/jboss/logmanager/ext/handlers/UdpOutputStream.java index e39da83d..757edde6 100644 --- a/ext/src/main/java/org/jboss/logmanager/ext/handlers/UdpOutputStream.java +++ b/ext/src/main/java/org/jboss/logmanager/ext/handlers/UdpOutputStream.java @@ -19,6 +19,7 @@ package org.jboss.logmanager.ext.handlers; +import java.io.Flushable; import java.io.IOException; import java.io.OutputStream; import java.net.DatagramPacket; @@ -27,15 +28,13 @@ import java.net.SocketAddress; import java.net.SocketException; -import org.jboss.logmanager.handlers.FlushableCloseable; - /** * An output stream that writes data to a {@link DatagramSocket DatagramSocket}. * * @author James R. Perkins */ @SuppressWarnings("WeakerAccess") -public class UdpOutputStream extends OutputStream implements FlushableCloseable { +public class UdpOutputStream extends OutputStream implements AutoCloseable, Flushable { private final DatagramSocket socket; private final SocketAddress socketAddress;