From c77ec6c5e48c89ae2b641aa58e50b207d3edeaf0 Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Tue, 1 Dec 2020 22:19:08 +0100 Subject: [PATCH] Just use a plain random to avoid a dependency on SecureRandom --- .../java/org/fusesource/jansi/internal/JansiLoader.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/fusesource/jansi/internal/JansiLoader.java b/src/main/java/org/fusesource/jansi/internal/JansiLoader.java index 38f800f4..c2676f44 100644 --- a/src/main/java/org/fusesource/jansi/internal/JansiLoader.java +++ b/src/main/java/org/fusesource/jansi/internal/JansiLoader.java @@ -15,7 +15,6 @@ *--------------------------------------------------------------------------*/ package org.fusesource.jansi.internal; -import java.io.BufferedOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; @@ -28,7 +27,7 @@ import java.util.LinkedList; import java.util.List; import java.util.Properties; -import java.util.UUID; +import java.util.Random; /** * Set the system properties, org.jansi.lib.path, org.jansi.lib.name, @@ -162,7 +161,7 @@ private static boolean extractAndLoadLibraryFile(String libFolderForCurrentOS, S String nativeLibraryFilePath = libFolderForCurrentOS + "/" + libraryFileName; // Include architecture name in temporary filename in order to avoid conflicts // when multiple JVMs with different architectures running at the same time - String uuid = UUID.randomUUID().toString(); + String uuid = randomUUID(); String extractedLibFileName = String.format("jansi-%s-%s-%s", getVersion(), uuid, libraryFileName); String extractedLckFileName = extractedLibFileName + ".lck"; @@ -221,6 +220,10 @@ private static boolean extractAndLoadLibraryFile(String libFolderForCurrentOS, S return false; } + private static String randomUUID() { + return Long.toHexString(new Random().nextLong()); + } + private static void copy(InputStream in, OutputStream out) throws IOException { byte[] buf = new byte[8192]; int n;