|
12 | 12 |
|
13 | 13 | import jakarta.annotation.PostConstruct; |
14 | 14 |
|
15 | | -import lombok.NoArgsConstructor; |
16 | 15 | import org.slf4j.Logger; |
17 | 16 | import org.slf4j.LoggerFactory; |
18 | 17 | import org.springframework.beans.factory.annotation.Autowired; |
@@ -42,6 +41,9 @@ public class DatabaseCleanupService { |
42 | 41 | private static final DateTimeFormatter FORMATTER = |
43 | 42 | DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
44 | 43 | private static final int EXEC_ID_LENGTH = 8; |
| 44 | + private static final int HEX_NIBBLE_SHIFT = 4; |
| 45 | + private static final int HEX_NIBBLE_MASK = 0x0F; |
| 46 | + private static final int HEX_RADIX = 16; |
45 | 47 |
|
46 | 48 | private final boolean cleanupEnabled; |
47 | 49 | private final boolean useTruncate; |
@@ -170,8 +172,10 @@ private static String createExecutionId() { |
170 | 172 | random.nextBytes(randomBytes); |
171 | 173 | final StringBuilder identifier = new StringBuilder(randomBytes.length * 2); |
172 | 174 | for (final byte randomByte : randomBytes) { |
173 | | - identifier.append(Character.forDigit((randomByte >>> 4) & 0x0F, 16)); |
174 | | - identifier.append(Character.forDigit(randomByte & 0x0F, 16)); |
| 175 | + identifier.append( |
| 176 | + Character.forDigit( |
| 177 | + (randomByte >>> HEX_NIBBLE_SHIFT) & HEX_NIBBLE_MASK, HEX_RADIX)); |
| 178 | + identifier.append(Character.forDigit(randomByte & HEX_NIBBLE_MASK, HEX_RADIX)); |
175 | 179 | } |
176 | 180 | return identifier.substring(0, EXEC_ID_LENGTH); |
177 | 181 | } |
|
0 commit comments