-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix DevUI fix serialization error on Throwable
Signed-off-by: Phillip Kruger <[email protected]>
- Loading branch information
1 parent
632f571
commit 613e164
Showing
6 changed files
with
70 additions
and
27 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
...t/src/main/java/io/quarkus/devui/deployment/jsonrpc/ByteArrayInputStreamDeserializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package io.quarkus.devui.deployment.jsonrpc; | ||
|
||
import static io.quarkus.vertx.runtime.jackson.JsonUtil.BASE64_DECODER; | ||
|
||
import java.io.ByteArrayInputStream; | ||
import java.io.IOException; | ||
|
||
import com.fasterxml.jackson.core.JsonParser; | ||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.databind.DeserializationContext; | ||
import com.fasterxml.jackson.databind.JsonDeserializer; | ||
import com.fasterxml.jackson.databind.exc.InvalidFormatException; | ||
|
||
public class ByteArrayInputStreamDeserializer extends JsonDeserializer<ByteArrayInputStream> { | ||
|
||
@Override | ||
public ByteArrayInputStream deserialize(JsonParser p, DeserializationContext ctxt) | ||
throws IOException, JsonProcessingException { | ||
String text = p.getText(); | ||
try { | ||
byte[] decode = BASE64_DECODER.decode(text); | ||
return new ByteArrayInputStream(decode); | ||
} catch (IllegalArgumentException e) { | ||
throw new InvalidFormatException(p, "Expected a base64 encoded byte array", text, ByteArrayInputStream.class); | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...ent/src/main/java/io/quarkus/devui/deployment/jsonrpc/ByteArrayInputStreamSerializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package io.quarkus.devui.deployment.jsonrpc; | ||
|
||
import static io.quarkus.vertx.runtime.jackson.JsonUtil.BASE64_ENCODER; | ||
|
||
import java.io.ByteArrayInputStream; | ||
import java.io.IOException; | ||
|
||
import com.fasterxml.jackson.core.JsonGenerator; | ||
import com.fasterxml.jackson.databind.JsonSerializer; | ||
import com.fasterxml.jackson.databind.SerializerProvider; | ||
|
||
import io.quarkus.deployment.util.IoUtil; | ||
|
||
public class ByteArrayInputStreamSerializer extends JsonSerializer<ByteArrayInputStream> { | ||
|
||
@Override | ||
public void serialize(ByteArrayInputStream value, JsonGenerator jgen, SerializerProvider provider) throws IOException { | ||
byte[] readBytes = IoUtil.readBytes(value); | ||
jgen.writeString(BASE64_ENCODER.encodeToString(readBytes)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters