diff --git a/CHANGELOG.md b/CHANGELOG.md index 0fe23e6..cee5d80 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file. ## Unreleased +## [1.1.7] - 2021-06-27 +### Changed +- Update project dependencies +- Remove dependency to ``commons-io`` +- Update to commons lang3 + ## [1.1.6] - 2021-02-06 ### Changed - Change interuppted behaviour in ``EBusLowLevelController`` thread diff --git a/pom.xml b/pom.xml index 17041b3..7e17b85 100644 --- a/pom.xml +++ b/pom.xml @@ -314,28 +314,21 @@ org.slf4j slf4j-api - 1.7.25 + 1.7.31 provided - commons-io - commons-io - 2.2 - provided - - - - commons-lang - commons-lang - 2.6 + org.apache.commons + commons-lang3 + 3.12.0 provided com.neuronrobotics nrjavaserial - 3.12.1 + 5.2.1 provided true @@ -351,7 +344,7 @@ com.google.code.gson gson - 2.5 + 2.8.6 provided diff --git a/src/main/java/de/csdev/ebus/cfg/std/EBusConfigurationReader.java b/src/main/java/de/csdev/ebus/cfg/std/EBusConfigurationReader.java index 7159801..7c6e51f 100644 --- a/src/main/java/de/csdev/ebus/cfg/std/EBusConfigurationReader.java +++ b/src/main/java/de/csdev/ebus/cfg/std/EBusConfigurationReader.java @@ -27,7 +27,7 @@ import com.google.gson.GsonBuilder; import com.google.gson.reflect.TypeToken; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.Nullable; import org.slf4j.Logger; diff --git a/src/main/java/de/csdev/ebus/command/EBusCommandRegistry.java b/src/main/java/de/csdev/ebus/command/EBusCommandRegistry.java index c7e9b59..aae554d 100644 --- a/src/main/java/de/csdev/ebus/command/EBusCommandRegistry.java +++ b/src/main/java/de/csdev/ebus/command/EBusCommandRegistry.java @@ -19,7 +19,7 @@ import java.util.Map; import java.util.Objects; -import org.apache.commons.lang.ObjectUtils; +import org.apache.commons.lang3.ObjectUtils; import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.Nullable; import org.slf4j.Logger; diff --git a/src/main/java/de/csdev/ebus/command/EBusCommandUtils.java b/src/main/java/de/csdev/ebus/command/EBusCommandUtils.java index 003803d..b7a7e88 100644 --- a/src/main/java/de/csdev/ebus/command/EBusCommandUtils.java +++ b/src/main/java/de/csdev/ebus/command/EBusCommandUtils.java @@ -16,7 +16,7 @@ import java.util.Map.Entry; import java.util.Objects; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.Nullable; import org.slf4j.Logger; diff --git a/src/main/java/de/csdev/ebus/command/datatypes/EBusAbstractType.java b/src/main/java/de/csdev/ebus/command/datatypes/EBusAbstractType.java index aeb3a94..fa292ab 100644 --- a/src/main/java/de/csdev/ebus/command/datatypes/EBusAbstractType.java +++ b/src/main/java/de/csdev/ebus/command/datatypes/EBusAbstractType.java @@ -17,8 +17,8 @@ import java.util.Objects; import java.util.TreeMap; -import org.apache.commons.lang.ArrayUtils; -import org.apache.commons.lang.reflect.FieldUtils; +import org.apache.commons.lang3.ArrayUtils; +import org.apache.commons.lang3.reflect.FieldUtils; import org.eclipse.jdt.annotation.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/de/csdev/ebus/command/datatypes/ext/EBusTypeDate.java b/src/main/java/de/csdev/ebus/command/datatypes/ext/EBusTypeDate.java index 2684718..35666c6 100644 --- a/src/main/java/de/csdev/ebus/command/datatypes/ext/EBusTypeDate.java +++ b/src/main/java/de/csdev/ebus/command/datatypes/ext/EBusTypeDate.java @@ -14,7 +14,7 @@ import java.util.GregorianCalendar; import java.util.Objects; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.eclipse.jdt.annotation.Nullable; import de.csdev.ebus.command.datatypes.EBusAbstractType; diff --git a/src/main/java/de/csdev/ebus/command/datatypes/ext/EBusTypeDateTime.java b/src/main/java/de/csdev/ebus/command/datatypes/ext/EBusTypeDateTime.java index 19398f2..a5a5229 100644 --- a/src/main/java/de/csdev/ebus/command/datatypes/ext/EBusTypeDateTime.java +++ b/src/main/java/de/csdev/ebus/command/datatypes/ext/EBusTypeDateTime.java @@ -14,7 +14,7 @@ import java.util.HashMap; import java.util.Map; -import org.apache.commons.lang.ArrayUtils; +import org.apache.commons.lang3.ArrayUtils; import org.eclipse.jdt.annotation.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/de/csdev/ebus/command/datatypes/ext/EBusTypeTime.java b/src/main/java/de/csdev/ebus/command/datatypes/ext/EBusTypeTime.java index a5884fc..72f7e42 100644 --- a/src/main/java/de/csdev/ebus/command/datatypes/ext/EBusTypeTime.java +++ b/src/main/java/de/csdev/ebus/command/datatypes/ext/EBusTypeTime.java @@ -13,7 +13,7 @@ import java.util.Calendar; import java.util.GregorianCalendar; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.eclipse.jdt.annotation.Nullable; import de.csdev.ebus.command.datatypes.EBusAbstractType; diff --git a/src/main/java/de/csdev/ebus/command/datatypes/std/AbstractEBusTypeNumber.java b/src/main/java/de/csdev/ebus/command/datatypes/std/AbstractEBusTypeNumber.java index da6eff6..915c77b 100644 --- a/src/main/java/de/csdev/ebus/command/datatypes/std/AbstractEBusTypeNumber.java +++ b/src/main/java/de/csdev/ebus/command/datatypes/std/AbstractEBusTypeNumber.java @@ -11,7 +11,7 @@ import java.math.BigDecimal; import java.math.BigInteger; -import org.apache.commons.lang.ArrayUtils; +import org.apache.commons.lang3.ArrayUtils; import org.eclipse.jdt.annotation.Nullable; import de.csdev.ebus.command.datatypes.EBusAbstractType; diff --git a/src/main/java/de/csdev/ebus/command/datatypes/std/AbstractEBusTypeUnsignedNumber.java b/src/main/java/de/csdev/ebus/command/datatypes/std/AbstractEBusTypeUnsignedNumber.java index 89bcc12..e3d1671 100644 --- a/src/main/java/de/csdev/ebus/command/datatypes/std/AbstractEBusTypeUnsignedNumber.java +++ b/src/main/java/de/csdev/ebus/command/datatypes/std/AbstractEBusTypeUnsignedNumber.java @@ -11,7 +11,7 @@ import java.math.BigDecimal; import java.math.BigInteger; -import org.apache.commons.lang.ArrayUtils; +import org.apache.commons.lang3.ArrayUtils; import org.eclipse.jdt.annotation.Nullable; import de.csdev.ebus.command.datatypes.EBusAbstractType; diff --git a/src/main/java/de/csdev/ebus/core/EBusEbusdController.java b/src/main/java/de/csdev/ebus/core/EBusEbusdController.java index 8015289..4e8a083 100644 --- a/src/main/java/de/csdev/ebus/core/EBusEbusdController.java +++ b/src/main/java/de/csdev/ebus/core/EBusEbusdController.java @@ -19,13 +19,13 @@ import java.nio.ByteBuffer; import java.util.Arrays; -import org.apache.commons.io.IOUtils; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.lang.math.NumberUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import de.csdev.ebus.core.EBusQueue.QueueEntry; +import de.csdev.ebus.utils.CommonsUtils; import de.csdev.ebus.utils.EBusUtils; /** @@ -399,13 +399,13 @@ private void disconnect() { stopSenderThread(); - IOUtils.closeQuietly(reader); + CommonsUtils.closeQuietly(reader); reader = null; - IOUtils.closeQuietly(writer); + CommonsUtils.closeQuietly(writer); writer = null; - IOUtils.closeQuietly(socket); + CommonsUtils.closeQuietly(socket); socket = null; directMode = false; diff --git a/src/main/java/de/csdev/ebus/core/connection/AbstractEBusConnection.java b/src/main/java/de/csdev/ebus/core/connection/AbstractEBusConnection.java index 27f9608..75886ca 100644 --- a/src/main/java/de/csdev/ebus/core/connection/AbstractEBusConnection.java +++ b/src/main/java/de/csdev/ebus/core/connection/AbstractEBusConnection.java @@ -12,10 +12,11 @@ import java.io.InputStream; import java.io.OutputStream; -import org.apache.commons.io.IOUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import de.csdev.ebus.utils.CommonsUtils; + /** * @author Christian Sowada - Initial contribution * @@ -37,8 +38,8 @@ public boolean close() throws IOException { outputStream.flush(); } - IOUtils.closeQuietly(inputStream); - IOUtils.closeQuietly(outputStream); + CommonsUtils.closeQuietly(inputStream); + CommonsUtils.closeQuietly(outputStream); inputStream = null; outputStream = null; diff --git a/src/main/java/de/csdev/ebus/core/connection/EBusJSerialCommConnection.java b/src/main/java/de/csdev/ebus/core/connection/EBusJSerialCommConnection.java index 23e6d9b..9d096b0 100644 --- a/src/main/java/de/csdev/ebus/core/connection/EBusJSerialCommConnection.java +++ b/src/main/java/de/csdev/ebus/core/connection/EBusJSerialCommConnection.java @@ -12,11 +12,11 @@ import com.fazecast.jSerialComm.SerialPort; -import org.apache.commons.io.IOUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import de.csdev.ebus.core.EBusConsts; +import de.csdev.ebus.utils.CommonsUtils; /** * @author Christian Sowada - Initial contribution @@ -70,8 +70,8 @@ public boolean close() throws IOException { // prevent an IllegalMonitorStateException error Thread shutdownThread = new Thread(() -> { - IOUtils.closeQuietly(inputStream); - IOUtils.closeQuietly(outputStream); + CommonsUtils.closeQuietly(inputStream); + CommonsUtils.closeQuietly(outputStream); if (serialPort != null) { serialPort.closePort(); diff --git a/src/main/java/de/csdev/ebus/core/connection/EBusSerialNRJavaSerialConnection.java b/src/main/java/de/csdev/ebus/core/connection/EBusSerialNRJavaSerialConnection.java index 7141647..a9867c1 100644 --- a/src/main/java/de/csdev/ebus/core/connection/EBusSerialNRJavaSerialConnection.java +++ b/src/main/java/de/csdev/ebus/core/connection/EBusSerialNRJavaSerialConnection.java @@ -11,11 +11,11 @@ import java.io.IOException; import java.util.TooManyListenersException; -import org.apache.commons.io.IOUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import de.csdev.ebus.core.EBusConsts; +import de.csdev.ebus.utils.CommonsUtils; import gnu.io.CommPortIdentifier; import gnu.io.NoSuchPortException; import gnu.io.PortInUseException; @@ -120,7 +120,7 @@ public boolean close() throws IOException { // prevent an IllegalMonitorStateException error Thread shutdownThread = new Thread(() -> { - IOUtils.closeQuietly(inputStream); + CommonsUtils.closeQuietly(inputStream); if (outputStream != null) { try { @@ -128,7 +128,7 @@ public boolean close() throws IOException { } catch (IOException e) { // noop } - IOUtils.closeQuietly(outputStream); + CommonsUtils.closeQuietly(outputStream); } if (serialPort != null) { diff --git a/src/main/java/de/csdev/ebus/service/device/EBusDeviceTable.java b/src/main/java/de/csdev/ebus/service/device/EBusDeviceTable.java index f31e4a0..5623114 100644 --- a/src/main/java/de/csdev/ebus/service/device/EBusDeviceTable.java +++ b/src/main/java/de/csdev/ebus/service/device/EBusDeviceTable.java @@ -23,7 +23,7 @@ import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; -import org.apache.commons.lang.ObjectUtils; +import org.apache.commons.lang3.ObjectUtils; import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.Nullable; import org.slf4j.Logger; diff --git a/src/main/java/de/csdev/ebus/utils/CommonsUtils.java b/src/main/java/de/csdev/ebus/utils/CommonsUtils.java new file mode 100644 index 0000000..134207b --- /dev/null +++ b/src/main/java/de/csdev/ebus/utils/CommonsUtils.java @@ -0,0 +1,75 @@ +/** + * Copyright (c) 2017-2021 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package de.csdev.ebus.utils; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.Reader; +import java.io.Writer; +import java.net.Socket; + +/** + * @author Christian Sowada - Initial contribution + * + */ +public class CommonsUtils { + + private CommonsUtils() { + } + + public static final void closeQuietly(InputStream stream) { + try { + if(stream != null) { + stream.close(); + } + } catch (IOException e) { + // noop + } + } + public static final void closeQuietly(OutputStream stream) { + try { + if(stream != null) { + stream.close(); + } + } catch (IOException e) { + // noop + } + } + + public static final void closeQuietly(Writer stream) { + try { + if(stream != null) { + stream.close(); + } + } catch (IOException e) { + // noop + } + } + + public static final void closeQuietly(Reader stream) { + try { + if(stream != null) { + stream.close(); + } + } catch (IOException e) { + // noop + } + } + + public static final void closeQuietly(Socket stream) { + try { + if(stream != null) { + stream.close(); + } + } catch (IOException e) { + // noop + } + } +} diff --git a/src/main/java/de/csdev/ebus/utils/EBusConsoleUtils.java b/src/main/java/de/csdev/ebus/utils/EBusConsoleUtils.java index 02bd258..10fadae 100644 --- a/src/main/java/de/csdev/ebus/utils/EBusConsoleUtils.java +++ b/src/main/java/de/csdev/ebus/utils/EBusConsoleUtils.java @@ -17,7 +17,7 @@ import java.util.Map.Entry; import java.util.Objects; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.Nullable; import org.slf4j.Logger; diff --git a/src/main/java/de/csdev/ebus/utils/EBusUtils.java b/src/main/java/de/csdev/ebus/utils/EBusUtils.java index e1ee115..7d1d0eb 100644 --- a/src/main/java/de/csdev/ebus/utils/EBusUtils.java +++ b/src/main/java/de/csdev/ebus/utils/EBusUtils.java @@ -11,7 +11,7 @@ import java.nio.ByteBuffer; import java.util.Objects; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.Nullable; diff --git a/src/main/java/de/csdev/ebus/utils/Emulator.java b/src/main/java/de/csdev/ebus/utils/Emulator.java index 18beb4f..594059a 100644 --- a/src/main/java/de/csdev/ebus/utils/Emulator.java +++ b/src/main/java/de/csdev/ebus/utils/Emulator.java @@ -18,7 +18,6 @@ import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; -import org.apache.commons.io.IOUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -161,7 +160,7 @@ public void close() { Thread.currentThread().interrupt(); } - IOUtils.closeQuietly(in); - IOUtils.closeQuietly(out); + CommonsUtils.closeQuietly(in); + CommonsUtils.closeQuietly(out); } }