New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[JENKINS-49070] Avoid serializing BigDecimal and BigInteger in the model #239
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🐝
val = val.doubleValue() | ||
} else if (val instanceof BigInteger) { | ||
if (val > Long.MAX_VALUE || val < Long.MIN_VALUE) { | ||
errorCollector.error(ModelASTValue.fromConstant(-1, e), Messages.ModelParser_BigIntegerValue()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe converting to Double? The current impl is fine for me though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nah, I want to stick with int-family rather than floating point. Anyway, tweaked in latest commit.
|
||
Object realVal = val.getValue(); | ||
|
||
assertTrue(realVal instanceof Double); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
redundant given test below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Touché.
if (val > Long.MAX_VALUE || val < Long.MIN_VALUE) { | ||
errorCollector.error(ModelASTValue.fromConstant(-1, e), Messages.ModelParser_BigIntegerValue()) | ||
} | ||
val = -1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uh, I think this will convert, say, new BigInteger(42)
to new Integer(-1)
which is not what you meant to do. Looks like you meant to put this line inside the above }
? Best to add a test confirming behavior of small integers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, yup. That -1
(when it's put in the right place!) ends up being ignored in practice, because the error trumps it, but yeah, it is in the wrong place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, and this situation can only, in practice, be hit if you specify a constant number greater than Long.MAX_VALUE
- we're only handling ConstantExpression
s here, so, say, 24
ends up as functionally equivalent to new Integer(24)
, while 2147483648
(i.e., one more than Integer.MAX_VALUE
) will be equivalent to new Long(2147483648)
. Groovy handles that behind the scenes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By the way, assuming the new test indeed reproduces the problem when run against JEP-200, I would suggest modifying your Jenkinsfile
to
- NEWER_CORE_VERSION = "2.89.2"
+ NEWER_CORE_VERSION = "2.103"
Good idea. Lemme see how that goes. |
Ok, this is weird. I think it might be an environmental issue with Docker on the agents. I'll revisit this tomorrow or the weekend. |
0.1
into aBigDecimal
. So let's convert that to aDouble
instead inModelASTValue#value
. And also, just barf out if for some reason someone tries to use aBigInteger
constant. Because no.