mirror of
https://github.com/floci-io/floci.git
synced 2026-11-24 06:20:24 -05:00
fix(dynamodb): stop getSortKeyNames() from corrupting persisted tables (#2463)
`GlobalSecondaryIndex`, `LocalSecondaryIndex`, and `TableDefinition` expose `getSortKeyNames()` with no setter. Jackson's getter-as-setter fallback appends into the list it returns, an immutable `Stream.toList()`, throwing `UnsupportedOperationException` whenever the schema has a RANGE key. On startup, the storage backends catch that as an unreadable file and reload with zero tables, taking down the whole store. Mark `getSortKeyNames()` `@JsonIgnore` on all three classes; it's already derived from `keySchema`. Fixes #2415 Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com>
This commit is contained in:
1 parent
87e804492a
commit
726c9c7446
5 files changed
+199
No files matched your search
+7
@@ -1,5 +1,6 @@
|
||||
package io.github.hectorvent.floci.services.dynamodb.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
@@ -82,7 +83,13 @@ public class GlobalSecondaryIndex {
|
||||
/**
|
||||
* Returns all sort key attribute names in key-schema order. For a composite sort key this
|
||||
* contains more than one element; ordering must consider all of them, not just the first.
|
||||
*
|
||||
* <p>{@code @JsonIgnore}d: it is derived from {@code keySchema} (redundant with
|
||||
* {@link #getSortKeyName()}), and without a backing setter Jackson's getter-as-setter
|
||||
* fallback tries to append into the immutable list this method returns, throwing
|
||||
* {@code UnsupportedOperationException} on deserialization whenever the index has a sort key.
|
||||
*/
|
||||
@JsonIgnore
|
||||
public List<String> getSortKeyNames() {
|
||||
return keySchema.stream()
|
||||
.filter(k -> "RANGE".equals(k.getKeyType()))
|
||||
|
||||
+7
@@ -1,5 +1,6 @@
|
||||
package io.github.hectorvent.floci.services.dynamodb.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
@@ -81,7 +82,13 @@ public class LocalSecondaryIndex {
|
||||
/**
|
||||
* Returns all sort key attribute names in key-schema order. For a composite sort key this
|
||||
* contains more than one element; ordering must consider all of them, not just the first.
|
||||
*
|
||||
* <p>{@code @JsonIgnore}d: it is derived from {@code keySchema} (redundant with
|
||||
* {@link #getSortKeyName()}), and without a backing setter Jackson's getter-as-setter
|
||||
* fallback tries to append into the immutable list this method returns, throwing
|
||||
* {@code UnsupportedOperationException} on deserialization whenever the index has a sort key.
|
||||
*/
|
||||
@JsonIgnore
|
||||
public List<String> getSortKeyNames() {
|
||||
return keySchema.stream()
|
||||
.filter(k -> "RANGE".equals(k.getKeyType()))
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package io.github.hectorvent.floci.services.dynamodb.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import io.github.hectorvent.floci.core.common.AwsArnUtils;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
@@ -226,7 +227,13 @@ public class TableDefinition {
|
||||
/**
|
||||
* Returns all sort key attribute names in key-schema order. For a composite sort key this
|
||||
* contains more than one element; ordering must consider all of them, not just the first.
|
||||
*
|
||||
* <p>{@code @JsonIgnore}d: it is derived from {@code keySchema} (redundant with
|
||||
* {@link #getSortKeyName()}), and without a backing setter Jackson's getter-as-setter
|
||||
* fallback tries to append into the immutable list this method returns, throwing
|
||||
* {@code UnsupportedOperationException} on deserialization whenever the table has a sort key.
|
||||
*/
|
||||
@JsonIgnore
|
||||
public List<String> getSortKeyNames() {
|
||||
return keySchema.stream()
|
||||
.filter(k -> "RANGE".equals(k.getKeyType()))
|
||||
|
||||
Reference in new issue
Block a user