mirror of
https://github.com/floci-io/floci.git
synced 2026-11-24 06:20:24 -05:00
fix(cloudmap): avoid SecureRandom in native image heap (#1289)
CloudMapService held a static final SecureRandom, which GraalVM evaluates at build time and bakes into the image heap with a cached seed, failing the native build (DisallowedImageHeapObjects). Make it a non-static instance field on the @ApplicationScoped bean so it is created at runtime instead, matching how other services (msk, opensearch, rds) construct SecureRandom locally. Also remove the stray src/main/resources/application.yml.bak that triggered an "Unrecognized configuration file" warning during the native build.
This commit is contained in:
1 parent
1095d934d0
commit
898615707d
2 files changed
+4
-192
No files matched your search
@@ -38,7 +38,8 @@ public class CloudMapService {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(CloudMapService.class);
|
||||
private static final String ALNUM = "abcdefghijklmnopqrstuvwxyz0123456789";
|
||||
private static final SecureRandom RANDOM = new SecureRandom();
|
||||
|
||||
private final SecureRandom random = new SecureRandom();
|
||||
|
||||
private final StorageBackend<String, Namespace> namespaceStore;
|
||||
private final StorageBackend<String, Service> serviceStore;
|
||||
@@ -540,7 +541,7 @@ public class CloudMapService {
|
||||
private String randomId(int length) {
|
||||
StringBuilder sb = new StringBuilder(length);
|
||||
for (int i = 0; i < length; i++) {
|
||||
sb.append(ALNUM.charAt(RANDOM.nextInt(ALNUM.length())));
|
||||
sb.append(ALNUM.charAt(random.nextInt(ALNUM.length())));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
@@ -549,7 +550,7 @@ public class CloudMapService {
|
||||
StringBuilder sb = new StringBuilder("Z");
|
||||
String chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||
for (int i = 0; i < 13; i++) {
|
||||
sb.append(chars.charAt(RANDOM.nextInt(chars.length())));
|
||||
sb.append(chars.charAt(random.nextInt(chars.length())));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user