Comments (5)
Actually, it is partially dependent on randomness.
I was able to trigger the exception consistently by providing my own (adversarial) Random subclass, whose nextBytes() method writes mostly 0xff values.
When _lastEntropy is set to 0xff ff ff ff ff ff ff ff ff ff, you get the exception if you call generate() 2 times within the same millisecond.
For 0xff ff ff ff ff ff ff ff ff 00, you get the exception if you call generate() 257 times within the same millisecond.
So in general (without the adversarial Random :)), there's a 1/2^80 probability to get the exception from the 2nd call during the same millisecond, and 1/2^72 probability to get the exception during the first 257 calls within the same millisecond.
from java-uuid-generator.
That would result in generating values "too fast": I forget what is the specific granularity (implementation came as contribution). The challenge is that for same millisecond-based timestamp implementation does use secondary counter, but its capacity is limited -- and I suspect that if you generated UUIDs in a busy loop, a single cpu can overflow it.
So failure would NOT be due to heavy load (quite the opposite actually) but on trying to generate LOTS of UUIDs (for regular time-based ones it's 10 million per second; for epoch maybe less).
I doubt typical applications could reach that rate for normal usage, but if that did happen, yes, waiting for 1 millisecond would be something simple to do. Plain old retry would keep on failing until System.currentTimeMilllis()
returns the next new value.
from java-uuid-generator.
Yes, that is compatible with my recollection of how things work.
The choice of random sequence (or, probability) changes number of "overlapping" uuids that can be generated for given time value.
And yes, with bad luck it could be a very low number.
I don't remember what specification says about choosing entropy values only up to half of max size: that would reduce likelihood of overrun, but also reduce entropy wrt security.
I am open to improvements but do not have enough time to spend on digging deep at this point, due to daytime work.
from java-uuid-generator.
Thank you, sir. You were very helpful.
from java-uuid-generator.
Thank you for your help here @gabrielbalan !
from java-uuid-generator.
Related Issues (20)
- `UUIDUtil.extractTimestamp()` is broken for versions 1 and 6 HOT 1
- Update About section of the repo HOT 1
- Release 5.1.0 wanted HOT 1
- defaultTimeBasedGenerator(): android.os.NetworkOnMainThreadException HOT 1
- License inconsistancy HOT 6
- Microsecond / nanosecond part of time based uuid set even if UUIDClock is millisecond precision HOT 2
- Release with UUID v7 support? HOT 5
- Enable "Reproducible Build"
- Ensure correct distinction between variant and version in documentation HOT 2
- UUID version 7 implementation sorting incorrect? HOT 11
- Type 1 UUID getTimestamp() synchronization leads to performance bottleneck HOT 5
- Add `Generators.defaultTimeBasedGenerator()` to use "default" interface address for time/based UUIDs
- TimeBasedEpochGenerator (UUIDv7) can't be provided a `UUIDClock` HOT 5
- Confusing comment wrt synchronization HOT 3
- Add `UUIDUtil.extractTimestamp()` for extracting 64-bit timestamp for all timestamp-based versions HOT 5
- Add code coverage reporting HOT 1
- Need more testing to increase code coverage (at least to 50%) HOT 7
- What is a valid UUID HOT 5
- Extract date time from UUID V7 HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from java-uuid-generator.