Skip to content

ArrayIndexOutOfBoundsException on createEntropy method #8

@dawidkarczewski

Description

@dawidkarczewski

Describe the bug
After many iterations of creating CUIDv2 by method CUID.randomCUID2() an exception is thrown:

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index -8 out of bounds for length 10
	at io.github.thibaultmeyer.cuid.CUID$CUIDv2.createEntropy(CUID.java:271)
	at io.github.thibaultmeyer.cuid.CUID.randomCUID2(CUID.java:71)
	at io.github.thibaultmeyer.cuid.CUID.randomCUID2(CUID.java:52)
	at org.example.Main.main(Main.java:8)

To Reproduce
Steps to reproduce the behavior:

Just generate CUID in the loop. It takes time (in my case over 1h), for example

import io.github.thibaultmeyer.cuid.CUID;

public class Main {
    public static void main(String[] args) {
        while (true) {
            CUID.randomCUID2();
        }
    }
}

Expected behavior
An exception should never be thrown

Additional context
Java 11

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions