Skip to content

Commit

Permalink
Just use a plain random to avoid a dependency on SecureRandom
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet committed Dec 1, 2020
1 parent 090132d commit c77ec6c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/main/java/org/fusesource/jansi/internal/JansiLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand Down Expand Up @@ -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";

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit c77ec6c

Please sign in to comment.