You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iceberg.apache.org by bl...@apache.org on 2022/03/22 19:36:16 UTC
[iceberg] branch master updated: Core: Add ErrorResponse to RESTSerializers (#4236)
This is an automated email from the ASF dual-hosted git repository.
blue pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iceberg.git
The following commit(s) were added to refs/heads/master by this push:
new 6653535 Core: Add ErrorResponse to RESTSerializers (#4236)
6653535 is described below
commit 6653535f75db503be02169f823d8191670e107b7
Author: Kyle Bendickson <kj...@gmail.com>
AuthorDate: Tue Mar 22 12:36:03 2022 -0700
Core: Add ErrorResponse to RESTSerializers (#4236)
---
.../org/apache/iceberg/rest/RESTSerializers.java | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/core/src/main/java/org/apache/iceberg/rest/RESTSerializers.java b/core/src/main/java/org/apache/iceberg/rest/RESTSerializers.java
index 90bb1cc..bda21cb 100644
--- a/core/src/main/java/org/apache/iceberg/rest/RESTSerializers.java
+++ b/core/src/main/java/org/apache/iceberg/rest/RESTSerializers.java
@@ -38,6 +38,8 @@ import org.apache.iceberg.UnboundSortOrder;
import org.apache.iceberg.catalog.Namespace;
import org.apache.iceberg.catalog.TableIdentifier;
import org.apache.iceberg.catalog.TableIdentifierParser;
+import org.apache.iceberg.rest.responses.ErrorResponse;
+import org.apache.iceberg.rest.responses.ErrorResponseParser;
import org.apache.iceberg.util.JsonUtil;
public class RESTSerializers {
@@ -48,6 +50,8 @@ public class RESTSerializers {
public static void registerAll(ObjectMapper mapper) {
SimpleModule module = new SimpleModule();
module
+ .addSerializer(ErrorResponse.class, new ErrorResponseSerializer())
+ .addDeserializer(ErrorResponse.class, new ErrorResponseDeserializer())
.addSerializer(TableIdentifier.class, new TableIdentifierSerializer())
.addDeserializer(TableIdentifier.class, new TableIdentifierDeserializer())
.addSerializer(Namespace.class, new NamespaceSerializer())
@@ -61,6 +65,22 @@ public class RESTSerializers {
mapper.registerModule(module);
}
+ public static class ErrorResponseDeserializer extends JsonDeserializer<ErrorResponse> {
+ @Override
+ public ErrorResponse deserialize(JsonParser p, DeserializationContext context) throws IOException {
+ JsonNode node = p.getCodec().readTree(p);
+ return ErrorResponseParser.fromJson(node);
+ }
+ }
+
+ public static class ErrorResponseSerializer extends JsonSerializer<ErrorResponse> {
+ @Override
+ public void serialize(ErrorResponse errorResponse, JsonGenerator gen, SerializerProvider serializers)
+ throws IOException {
+ ErrorResponseParser.toJson(errorResponse, gen);
+ }
+ }
+
public static class NamespaceDeserializer extends JsonDeserializer<Namespace> {
@Override
public Namespace deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {