diff --git a/build.gradle b/build.gradle index 90347de..f3265c7 100644 --- a/build.gradle +++ b/build.gradle @@ -55,7 +55,7 @@ ospackage { buildRpm { dependsOn startShadowScripts - os = LINUX + os = "LINUX" } buildDeb { diff --git a/src/main/java/biz/nellemann/syslogd/Facility.java b/src/main/java/biz/nellemann/syslogd/Facility.java index 9b4107b..001a7c4 100644 --- a/src/main/java/biz/nellemann/syslogd/Facility.java +++ b/src/main/java/biz/nellemann/syslogd/Facility.java @@ -72,7 +72,7 @@ public enum Facility { return this.facilityNumber; } - private Integer facilityNumber; + private final Integer facilityNumber; Facility(int facilityNumber) { this.facilityNumber = facilityNumber; } diff --git a/src/main/java/biz/nellemann/syslogd/Severity.java b/src/main/java/biz/nellemann/syslogd/Severity.java index ffb9a5d..4364afb 100644 --- a/src/main/java/biz/nellemann/syslogd/Severity.java +++ b/src/main/java/biz/nellemann/syslogd/Severity.java @@ -40,7 +40,7 @@ public enum Severity { return this.severityNumber; } - private Integer severityNumber; + private final Integer severityNumber; Severity(int severityNumber) { this.severityNumber = severityNumber; } diff --git a/src/main/java/biz/nellemann/syslogd/TcpServer.java b/src/main/java/biz/nellemann/syslogd/TcpServer.java index 24bdc44..aca61ee 100644 --- a/src/main/java/biz/nellemann/syslogd/TcpServer.java +++ b/src/main/java/biz/nellemann/syslogd/TcpServer.java @@ -26,7 +26,7 @@ import java.util.List; public class TcpServer { - private int port; + private final int port; private ServerSocket serverSocket; TcpServer() { @@ -52,7 +52,7 @@ public class TcpServer { * Event Listener Configuration */ - protected List eventListeners = new ArrayList<>(); + protected final List eventListeners = new ArrayList<>(); public synchronized void addEventListener( LogListener l ) { eventListeners.add( l ); @@ -66,9 +66,9 @@ public class TcpServer { private static class ClientHandler extends Thread { - protected List eventListeners; + protected final List eventListeners; - private Socket clientSocket; + private final Socket clientSocket; private BufferedReader in; public ClientHandler(Socket socket, List eventListeners) { diff --git a/src/main/java/biz/nellemann/syslogd/UdpServer.java b/src/main/java/biz/nellemann/syslogd/UdpServer.java index 0b78379..3383003 100644 --- a/src/main/java/biz/nellemann/syslogd/UdpServer.java +++ b/src/main/java/biz/nellemann/syslogd/UdpServer.java @@ -18,13 +18,14 @@ package biz.nellemann.syslogd; import java.io.IOException; import java.net.DatagramPacket; import java.net.DatagramSocket; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Iterator; import java.util.List; public class UdpServer extends Thread { - protected DatagramSocket socket = null; + protected DatagramSocket socket; protected boolean listen = true; public UdpServer() throws IOException { @@ -44,7 +45,7 @@ public class UdpServer extends Thread { while (listen) { try { socket.receive(packet); - String packetData = new String(packet.getData(), packet.getOffset(), packet.getLength(), "UTF8"); + String packetData = new String(packet.getData(), packet.getOffset(), packet.getLength(), StandardCharsets.UTF_8); sendEvent(packetData); } catch (Exception e) { e.printStackTrace();