@@ -115,23 +115,23 @@ private SaltEntry[] rotateSalts(SaltEntry[] oldSalts, List<SaltEntry> saltsToRot
115115 return updatedSalts ;
116116 }
117117
118- private SaltEntry updateSalt (SaltEntry oldSalt , TargetDate targetDate , boolean shouldRotate , KeyIdGenerator keyIdGenerator ) throws Exception {
119- var lastUpdated = shouldRotate ? targetDate .asEpochMs () : oldSalt .lastUpdated ();
120- var refreshFrom = calculateRefreshFrom (oldSalt , targetDate );
121- var currentSalt = calculateCurrentSalt (oldSalt , shouldRotate );
122- var previousSalt = calculatePreviousSalt (oldSalt , shouldRotate , targetDate );
123- var currentKey = calculateCurrentKey ( oldSalt , shouldRotate , keyIdGenerator );
124- var previousKey = calculatePreviousKey ( oldSalt ,shouldRotate , targetDate );
118+ private SaltEntry updateSalt (SaltEntry oldBucket , TargetDate targetDate , boolean shouldRotate , KeyIdGenerator keyIdGenerator ) throws Exception {
119+ var lastUpdated = shouldRotate ? targetDate .asEpochMs () : oldBucket .lastUpdated ();
120+ var refreshFrom = calculateRefreshFrom (oldBucket , targetDate );
121+ var currentSalt = calculateCurrentSalt (oldBucket , shouldRotate );
122+ var previousSalt = calculatePreviousSalt (oldBucket , shouldRotate , targetDate );
123+ var currentKeySalt = calculateCurrentKeySalt ( oldBucket , shouldRotate , keyIdGenerator );
124+ var previousKeySalt = calculatePreviousKeySalt ( oldBucket ,shouldRotate , targetDate );
125125
126126 return new SaltEntry (
127- oldSalt .id (),
128- oldSalt .hashedId (),
127+ oldBucket .id (),
128+ oldBucket .hashedId (),
129129 lastUpdated ,
130130 currentSalt ,
131131 refreshFrom ,
132132 previousSalt ,
133- currentKey ,
134- previousKey
133+ currentKeySalt ,
134+ previousKeySalt
135135 );
136136 }
137137
@@ -141,9 +141,15 @@ private long calculateRefreshFrom(SaltEntry salt, TargetDate targetDate) {
141141 }
142142
143143 private String calculateCurrentSalt (SaltEntry salt , boolean shouldRotate ) throws Exception {
144- return shouldRotate ?
145- ENABLE_V4_RAW_UID ? null : this .keyGenerator .generateRandomKeyString (32 )
146- : salt .currentSalt ();
144+ if (shouldRotate ) {
145+ if (ENABLE_V4_RAW_UID ) {
146+ return null ;
147+ }
148+ else {
149+ return this .keyGenerator .generateRandomKeyString (32 );
150+ }
151+ }
152+ return salt .currentSalt ();
147153 }
148154
149155 private String calculatePreviousSalt (SaltEntry salt , boolean shouldRotate , TargetDate targetDate ) {
@@ -156,7 +162,7 @@ private String calculatePreviousSalt(SaltEntry salt, boolean shouldRotate, Targe
156162 return null ;
157163 }
158164
159- private SaltEntry .KeyMaterial calculateCurrentKey (SaltEntry salt , boolean shouldRotate , KeyIdGenerator keyIdGenerator ) throws Exception {
165+ private SaltEntry .KeyMaterial calculateCurrentKeySalt (SaltEntry bucket , boolean shouldRotate , KeyIdGenerator keyIdGenerator ) throws Exception {
160166 if (shouldRotate ) {
161167 if (ENABLE_V4_RAW_UID ) {
162168 return new SaltEntry .KeyMaterial (
@@ -168,15 +174,15 @@ private SaltEntry.KeyMaterial calculateCurrentKey(SaltEntry salt, boolean should
168174 return null ;
169175 }
170176 }
171- return salt .currentKey ();
177+ return bucket .currentKey ();
172178 }
173179
174- private SaltEntry .KeyMaterial calculatePreviousKey (SaltEntry salt , boolean shouldRotate , TargetDate targetDate ) {
180+ private SaltEntry .KeyMaterial calculatePreviousKeySalt (SaltEntry bucket , boolean shouldRotate , TargetDate targetDate ) {
175181 if (shouldRotate ) {
176- return salt .currentKey ();
182+ return bucket .currentKey ();
177183 }
178- if (targetDate .saltAgeInDays (salt ) < 90 ) {
179- return salt .previousKey ();
184+ if (targetDate .saltAgeInDays (bucket ) < 90 ) {
185+ return bucket .previousKey ();
180186 }
181187 return null ;
182188 }
0 commit comments