diff --git a/sharepoint/api/src/main/java/de/muehlencord/shared/sharepoint/api/SPHelper.java b/sharepoint/api/src/main/java/de/muehlencord/shared/sharepoint/api/SPHelper.java index 068b86d..a997e14 100644 --- a/sharepoint/api/src/main/java/de/muehlencord/shared/sharepoint/api/SPHelper.java +++ b/sharepoint/api/src/main/java/de/muehlencord/shared/sharepoint/api/SPHelper.java @@ -1,7 +1,6 @@ package de.muehlencord.shared.sharepoint.api; import java.text.SimpleDateFormat; -import java.time.format.DateTimeFormatter; import java.util.Date; /** @@ -18,7 +17,13 @@ public class SPHelper { if (d == null) { return ""; } - return dateOnlyFormat.format(d); + + String result; + synchronized (dateOnlyFormat) { + result = dateOnlyFormat.format(d); + } + return result; + } /* -- Format for DateTime Field -- */ @@ -26,8 +31,12 @@ public class SPHelper { if (d == null) { return ""; } - - return dateTimeFormat.format(d); + String result; + + synchronized (dateTimeFormat) { + result = dateTimeFormat.format(d); + } + return result; } } diff --git a/util/src/main/java/de/muehlencord/shared/util/file/FileUtil.java b/util/src/main/java/de/muehlencord/shared/util/file/FileUtil.java index ed25107..50d09a8 100644 --- a/util/src/main/java/de/muehlencord/shared/util/file/FileUtil.java +++ b/util/src/main/java/de/muehlencord/shared/util/file/FileUtil.java @@ -1,7 +1,3 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ package de.muehlencord.shared.util.file; import static de.muehlencord.shared.util.StringUtil.getStackTraceString; @@ -20,7 +16,6 @@ import java.text.Format; import static java.util.Arrays.asList; import java.util.LinkedList; import java.util.List; -import java.util.logging.Level; import org.apache.log4j.Logger; import static org.apache.log4j.Logger.getLogger; @@ -170,17 +165,17 @@ public abstract class FileUtil { throw new IOException("Cannot get MD5 MessageDigest instance"); } - try (InputStream is = Files.newInputStream(Paths.get(fileName))) { - DigestInputStream dis = new DigestInputStream(is, md); - int nread; + try (InputStream is = Files.newInputStream(Paths.get(fileName)); + DigestInputStream dis = new DigestInputStream(is, md)) { + byte[] buffer = new byte[4096]; - while ((nread = dis.read(buffer)) != -1) { + while ((dis.read(buffer)) != -1) { md.update(buffer); } } byte[] digest = md.digest(); - //convert the byte to hex format method 1 + //convert the byte to hex format method 1 StringBuilder sb = new StringBuilder(); for (int i = 0; i < digest.length; i++) { sb.append(Integer.toString((digest[i] & 0xff) + 0x100, 16).substring(1));