@@ -27,28 +27,24 @@ public SaltEntry[] parseFileLines(String[] saltFileLines, Integer size) {
2727
2828 private SaltEntry parseLine (String line , int lineNumber ) {
2929 try {
30- final String [] fields = line .split ("," );
31-
30+ final String [] fields = line .split ("," , -1 );
3231 final long id = Integer .parseInt (fields [0 ]);
3332 final String hashedId = this .idHashingScheme .encode (id );
3433 final long lastUpdated = Long .parseLong (fields [1 ]);
35- final String salt = fields [2 ].isEmpty () ? null : fields [2 ];
36- final Long refreshFrom = Long .parseLong (fields [3 ]);
34+ final String salt = trimToNull (fields [2 ]);
35+ final long refreshFrom = Long .parseLong (fields [3 ]);
36+ final String previousSalt = trimToNull (fields [4 ]);
3737
38- String previousSalt = null ;
38+ // TODO: The fields below should stop being optional once refreshable UIDs features get rolled out in production. We can remove them one by one as necessary.
39+ // AU, 2025/07/28
3940 SaltEntry .KeyMaterial currentKeySalt = null ;
4041 SaltEntry .KeyMaterial previousKeySalt = null ;
41-
42- if (fields .length > 4 ) {
43- previousSalt = fields [4 ].isEmpty () ? null : fields [4 ];
42+ if (trimToNull (fields [5 ]) != null && trimToNull (fields [6 ]) != null ) {
43+ currentKeySalt = new SaltEntry .KeyMaterial (Integer .parseInt (fields [5 ]), fields [6 ], fields [7 ]);
4444 }
4545
46- if (fields .length > 7 ) {
47- currentKeySalt = fields [5 ].isEmpty () ? null : new SaltEntry .KeyMaterial (Integer .parseInt (fields [5 ]), fields [6 ], fields [7 ]);
48- }
49-
50- if (fields .length > 10 ) {
51- previousKeySalt = fields [8 ].isEmpty () ? null : new SaltEntry .KeyMaterial (Integer .parseInt (fields [8 ]), fields [9 ], fields [10 ]);
46+ if (trimToNull (fields [8 ]) != null && trimToNull (fields [9 ]) != null ) {
47+ previousKeySalt = new SaltEntry .KeyMaterial (Integer .parseInt (fields [8 ]), fields [9 ], fields [10 ]);
5248 }
5349
5450 return new SaltEntry (id , hashedId , lastUpdated , salt , refreshFrom , previousSalt , currentKeySalt , previousKeySalt );
@@ -57,4 +53,7 @@ private SaltEntry parseLine(String line, int lineNumber) {
5753 }
5854 }
5955
56+ private String trimToNull (String s ) {
57+ return s == null || s .isBlank () ? null : s .trim ();
58+ }
6059}
0 commit comments