|
22 | 22 |
|
23 | 23 | import com.fasterxml.jackson.core.JsonParser; |
24 | 24 | import com.fasterxml.jackson.databind.DeserializationContext; |
25 | | -import com.fasterxml.jackson.databind.JsonNode; |
26 | 25 | import com.fasterxml.jackson.databind.ObjectMapper; |
27 | 26 | import com.fasterxml.jackson.databind.deser.std.StdDeserializer; |
28 | 27 | import com.fasterxml.jackson.databind.node.ObjectNode; |
@@ -50,16 +49,16 @@ public Transaction deserialize(JsonParser jsonParser, DeserializationContext ctx |
50 | 49 | final ObjectMapper objectMapper = (ObjectMapper) jsonParser.getCodec(); |
51 | 50 | final ObjectNode objectNode = objectMapper.readTree(jsonParser); |
52 | 51 |
|
53 | | - final JsonNode transactionTypeJsonNode = objectNode.get("TransactionType"); |
54 | | - final TransactionType transactionType = TransactionType.forValue(transactionTypeJsonNode.asText()); |
| 52 | + TransactionType transactionType = TransactionType.forValue(objectNode.get("TransactionType").asText()); |
55 | 53 | final Class<? extends Transaction> transactionTypeClass = Transaction.typeMap.inverse().get(transactionType); |
56 | 54 |
|
57 | | - // Remove the `Account` property from any incoming `UnlModify` JSON about to be deserialized. This is because the |
58 | | - // JSON returned by the rippled/clio API v1 has a bug where the account value in `UnlModify` transactions is an |
59 | | - // empty string. In this case, the Java value for the `Account` property is always set to ACCOUNT_ZERO via a default |
60 | | - // method, so this property is removed from incoming JSON before deserialization because it's not needed (the |
61 | | - // default method handles population in Java) and if not removed, this field will end up in the `unknownFields` |
62 | | - // map of the ultimate Java object, which is incorrect. |
| 55 | + // Fixes #590 by removing the `Account` property from any incoming `UnlModify` JSON about to be deserialized. |
| 56 | + // This fixes #590 because the JSON returned by the rippled/clio API v1 has a bug where the account value in |
| 57 | + // `UnlModify` transactions is an empty string. When this value is deserialized, an exception is thrown because |
| 58 | + // the empty string value is not a valid `Address`. By removing the property from incoming JSON, the Java value |
| 59 | + // for the `Account` property is always set to ACCOUNT_ZERO via a default method. One other side effect of this |
| 60 | + // fix is that `Account` property will not be errantly added to `unknownFields` map of the ultimate Java object, |
| 61 | + // which is incorrect. |
63 | 62 | if (UnlModify.class.isAssignableFrom(transactionTypeClass)) { |
64 | 63 | objectNode.remove("Account"); |
65 | 64 | } |
|
0 commit comments