Skip to content

Commit

Permalink
Merge branch '2.17'
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Dec 16, 2023
2 parents 7f7c868 + 3401f2b commit 70ad151
Showing 1 changed file with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1742,6 +1742,10 @@ public JsonGenerator writeNumber(String encodedValue) throws JacksonException

// Let's see if it's integral or not
int i = neg ? 1 : 0;
if (i >= len) {
_writeIntegralNumber(encodedValue, neg);
return this;
}
while (true) {
char c = encodedValue.charAt(i);
if (c > '9' || c < '0') {
Expand All @@ -1765,16 +1769,19 @@ protected void _writeIntegralNumber(String enc, boolean neg) throws JacksonExcep
// let's do approximate optimization
try {
if (len <= 9) {
writeNumber(Integer.parseInt(enc));
// Avoid exception from empty String
if (len > 0) {
writeNumber(Integer.parseInt(enc));
}
} else if (len <= 18) {
writeNumber(Long.parseLong(enc));
} else {
writeNumber(new BigInteger(enc));
writeNumber(NumberInput.parseBigInteger(enc, false));
}
} catch (NumberFormatException e) {
throw _constructWriteException("Invalid String representation for Number ('"+enc
+"'); can not write using Smile format");
}
return;
} catch (NumberFormatException e) { }
throw _constructWriteException("Invalid String representation for Number ('"+enc
+"'); can not write using Smile format");
}

protected void _writeDecimalNumber(String enc) throws JacksonException
Expand Down

0 comments on commit 70ad151

Please sign in to comment.