huaxingao commented on code in PR #5122:
URL: https://github.com/apache/polaris/pull/5122#discussion_r3642013820
##########
runtime/service/src/main/java/org/apache/polaris/service/idempotency/EntityIdempotency.java:
##########
@@ -130,24 +126,24 @@ public static Map<String, String> recordKey(
}
private static List<KeyEntry> decode(String raw) {
- if (raw == null || raw.isEmpty()) {
+ if (raw == null || !raw.startsWith(FORMAT_SMILE_V1)) {
return List.of();
}
- if (!raw.startsWith(WINDOW_FORMAT_SMILE_V1)) {
- throw new IllegalArgumentException("Unrecognized idempotency key window
format");
- }
- byte[] smile =
Base64.getUrlDecoder().decode(raw.substring(WINDOW_FORMAT_SMILE_V1.length()));
+ // An unreadable window (bad base64 or SMILE decode failure) is treated as
no live keys rather
+ // than failing the operation: a corrupt property degrades to normal
behavior and the next
+ // recordKey overwrites it.
try {
+ byte[] smile =
Base64.getUrlDecoder().decode(raw.substring(FORMAT_SMILE_V1.length()));
return SMILE_MAPPER.readValue(smile, new TypeReference<List<KeyEntry>>()
{});
- } catch (IOException e) {
- throw new RuntimeException("Failed to decode idempotency key window", e);
+ } catch (IllegalArgumentException | IOException e) {
+ return List.of();
Review Comment:
Sounds good! Will add one.
--
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]