You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@johnzon.apache.org by st...@apache.org on 2018/07/23 11:17:16 UTC
johnzon git commit: JOHNZON-177 soften the rules at least for bytes.
Repository: johnzon
Updated Branches:
refs/heads/master 50b8fc3e8 -> 31fe53aad
JOHNZON-177 soften the rules at least for bytes.
This is only an intermediate solution!
We will have to ship a proper solution until it's clear how
it will be solved on a spec level
Project: http://git-wip-us.apache.org/repos/asf/johnzon/repo
Commit: http://git-wip-us.apache.org/repos/asf/johnzon/commit/31fe53aa
Tree: http://git-wip-us.apache.org/repos/asf/johnzon/tree/31fe53aa
Diff: http://git-wip-us.apache.org/repos/asf/johnzon/diff/31fe53aa
Branch: refs/heads/master
Commit: 31fe53aadcaa18f94694addafb91bf04a5412f57
Parents: 50b8fc3
Author: Mark Struberg <st...@apache.org>
Authored: Mon Jul 23 13:15:56 2018 +0200
Committer: Mark Struberg <st...@apache.org>
Committed: Mon Jul 23 13:15:56 2018 +0200
----------------------------------------------------------------------
.../java/org/apache/johnzon/mapper/MappingParserImpl.java | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/johnzon/blob/31fe53aa/johnzon-mapper/src/main/java/org/apache/johnzon/mapper/MappingParserImpl.java
----------------------------------------------------------------------
diff --git a/johnzon-mapper/src/main/java/org/apache/johnzon/mapper/MappingParserImpl.java b/johnzon-mapper/src/main/java/org/apache/johnzon/mapper/MappingParserImpl.java
index 3dbc337..e2dc84d 100644
--- a/johnzon-mapper/src/main/java/org/apache/johnzon/mapper/MappingParserImpl.java
+++ b/johnzon-mapper/src/main/java/org/apache/johnzon/mapper/MappingParserImpl.java
@@ -557,11 +557,15 @@ public class MappingParserImpl implements MappingParser {
}
if (type == Byte.class || type == byte.class) {
- byte byteVal = (byte) intValue;
- if (intValue != byteVal) {
+
+ // bytes have a special handling as they are often used
+ // to transport binary. So we have to pass on the full 8 bit.
+ // TODO: ATTENTION: this is only an intermediate solution until JOHNZON-177
+ // resp https://github.com/eclipse-ee4j/jsonb-api/issues/82 is properly specced
+ if (intValue < -128 || intValue > 255) {
throw new java.lang.ArithmeticException("Overflow");
}
- return byteVal;
+ return (byte) intValue;
}
} else if (JsonString.class.isInstance(jsonValue)) {