Skip to content

Commit

Permalink
优化 records 类的编码方式
Browse files Browse the repository at this point in the history
  • Loading branch information
vnobo committed Oct 27, 2023
1 parent e960d3e commit 12896ad
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.platform.boot.commons;

import com.platform.boot.commons.annotation.exception.RestServerException;

import java.io.Serializable;

/**
Expand Down Expand Up @@ -27,7 +29,9 @@ public String nextIdStr() {
public synchronized long nextId() {
long timestamp = System.currentTimeMillis();
if (timestamp < lastTimestamp) {
throw new RuntimeException("Invalid system clock");
throw RestServerException.withMsg("Invalid system clock error!",
"Invalid lastTimestamp > currentTimeMillis is error." +
" Current time :" + timestamp + ",Last timestamp :" + lastTimestamp);
}
if (timestamp == lastTimestamp) {
sequence = (sequence + 1) & 4095;
Expand Down

0 comments on commit 12896ad

Please sign in to comment.