@Test public void testLoadSecretKey2() throws Exception { SecretKey secretKey = Encryption.generateNewKey(); File secretKeyFile = File.createTempFile("glowroot-unit-test-", ""); byte[] encodedKey = secretKey.getEncoded(); Files.write(encodedKey, secretKeyFile); LazySecretKey lazySecretKey = new LazySecretKeyImpl(secretKeyFile); assertThat(lazySecretKey.getExisting().getEncoded()).isEqualTo(encodedKey); secretKeyFile.delete(); }
@Override public @Nullable SecretKey getExisting() throws Exception { synchronized (secretFile) { if (secretKey == null && secretFile.exists()) { secretKey = loadKey(secretFile); } return secretKey; } }
LazySecretKeyImpl implements LazySecretKey { @Override public @Nullable SecretKey getExisting() throws Exception { synchronized (secretFile) { if (secretKey == null && secretFile.exists()) { secretKey = loadKey(secretFile); } return secretKey; } } }
LazySecretKeyImpl implements LazySecretKey { @Override public @Nullable SecretKey getExisting() throws Exception { synchronized (secretFile) { if (secretKey == null && secretFile.exists()) { secretKey = loadKey(secretFile); } return secretKey; } } LazySecretKeyImpl(File secretFile); }
LazySecretKeyImpl implements LazySecretKey { @Override public @Nullable SecretKey getExisting() throws Exception { synchronized (secretFile) { if (secretKey == null && secretFile.exists()) { secretKey = loadKey(secretFile); } return secretKey; } } LazySecretKeyImpl(File secretFile); @Override @Nullable SecretKey getExisting(); @Override SecretKey getOrCreate(); }
LazySecretKeyImpl implements LazySecretKey { @Override public @Nullable SecretKey getExisting() throws Exception { synchronized (secretFile) { if (secretKey == null && secretFile.exists()) { secretKey = loadKey(secretFile); } return secretKey; } } LazySecretKeyImpl(File secretFile); @Override @Nullable SecretKey getExisting(); @Override SecretKey getOrCreate();  }