sashapolo commented on code in PR #10118:
URL: https://github.com/apache/ignite/pull/10118#discussion_r910912783
##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/serializer/RecordDataV1Serializer.java:
##########
@@ -287,57 +278,45 @@ private boolean needEncryption(int grpId) {
* @throws IOException If failed.
* @throws IgniteCheckedException If failed.
*/
- private T3<ByteBufferBackedDataInput, Integer, RecordType>
readEncryptedData(
+ private EncryptedData readEncryptedData(
ByteBufferBackedDataInput in,
boolean readType,
boolean readKeyId
) throws IOException, IgniteCheckedException {
int grpId = in.readInt();
int encRecSz = in.readInt();
- RecordType plainRecType = null;
-
- if (readType)
- plainRecType = RecordV1Serializer.readRecordType(in);
+ RecordType plainRecType = readType ?
RecordV1Serializer.readRecordType(in) : null;
int keyId = readKeyId ? in.readUnsignedByte() :
GridEncryptionManager.INITIAL_KEY_ID;
- byte[] encData = new byte[encRecSz];
+ // Encryption Manager can be null during offline WAL iteration
+ if (encMgr == null) {
+ int skipped = in.skipBytes(encRecSz);
- in.readFully(encData);
+ assert skipped == encRecSz;
- GroupKey grpKey = encMgr.groupKey(grpId, keyId);
+ return new EncryptedData(null, plainRecType, grpId);
+ }
- if (grpKey == null)
- return new T3<>(null, grpId, plainRecType);
+ GroupKey grpKey = encMgr.groupKey(grpId, keyId);
- byte[] clData = encSpi.decrypt(encData, grpKey.key());
+ // Encryption key is not available when restoring the MetaStorage
+ if (grpKey == null) {
+ int skipped = in.skipBytes(encRecSz);
Review Comment:
This block is three lines of code and used in only two places inside one
method. I think it is better as it is
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]