Skip to content

Commit c9621aa

Browse files
committed
HHH-18377 Fix NPE for private static final field
1 parent ebcbeba commit c9621aa

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

hibernate-core/src/main/java/org/hibernate/id/uuid/UuidVersion6Strategy.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,13 @@
3636
* @author Cedomir Igaly
3737
*/
3838
public class UuidVersion6Strategy implements UUIDGenerationStrategy, UuidValueGenerator {
39-
4039
public static final UuidVersion6Strategy INSTANCE = new UuidVersion6Strategy();
4140

42-
private static final Instant EPOCH_1582 = LocalDate.of( 1582, 10, 15 )
43-
.atStartOfDay( ZoneId.of( "UTC" ) )
44-
.toInstant();
45-
4641
private static class Holder {
4742
static final SecureRandom numberGenerator = new SecureRandom();
43+
static final Instant EPOCH_1582 = LocalDate.of( 1582, 10, 15 )
44+
.atStartOfDay( ZoneId.of( "UTC" ) )
45+
.toInstant();
4846
}
4947

5048
private final Lock lock = new ReentrantLock( true );
@@ -112,7 +110,7 @@ private long getSequence(final long currentTimestamp) {
112110
}
113111

114112
private static long getCurrentTimestamp() {
115-
final Duration duration = Duration.between( EPOCH_1582, Instant.now() );
113+
final Duration duration = Duration.between( Holder.EPOCH_1582, Instant.now() );
116114
return duration.toSeconds() * 10_000_000 + duration.toNanosPart() / 100;
117115
}
118116
}

0 commit comments

Comments
 (0)