in encryption/src/main/java/org/apache/solr/encryption/EncryptionDirectory.java [129:158]
protected IndexOutput maybeWrapOutput(IndexOutput indexOutput) throws IOException {
String fileName = indexOutput.getName();
assert !fileName.startsWith(IndexFileNames.SEGMENTS);
if (fileName.startsWith(IndexFileNames.PENDING_SEGMENTS)) {
// The pending_segments file should not be encrypted. Do not wrap the IndexOutput.
// It also means a commit has started, so set the flag to read the commit user data
// next time we need it.
shouldReadCommitUserData = true;
return indexOutput;
}
if (!keyManager.isEncryptable(fileName)) {
// The file should not be encrypted, based on its name. Do not wrap the IndexOutput.
return indexOutput;
}
boolean success = false;
try {
String keyRef = getKeyRefForWriting(indexOutput);
if (keyRef != null) {
// The IndexOutput has to be wrapped to be encrypted with the key.
indexOutput = new EncryptingIndexOutput(indexOutput, getKeySecret(keyRef), encrypterFactory);
}
success = true;
} finally {
if (!success) {
// Something went wrong. Close the IndexOutput before the exception continues.
IOUtils.closeWhileHandlingException(indexOutput);
}
}
return indexOutput;
}