Skip to content
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

Add SpEL support for float literals [SPR-9486] #14121

Closed
spring-projects-issues opened this issue Jun 8, 2012 · 8 comments
Closed

Add SpEL support for float literals [SPR-9486] #14121

spring-projects-issues opened this issue Jun 8, 2012 · 8 comments
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Jun 8, 2012

Satyapal Reddy opened SPR-9486 and commented

I have two functions:

public class FunctionsClass {
  public int abs(int value) { return Math.abs(value); }
  public float abs(float value) { return Math.abs(value); } }
}

and when I execute the test with following code:

FunctionsClass testObject = new FunctionsClass();
StandardEvaluationContext context = new StandardEvaluationContext();
org.springframework.expression.Expression expression = parser.parseExpression("abs(-10.2f)");
Number result = expression.getValue(context, testObject, Number.class);

it fails with:

Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1033E:(pos 0): Method call of 'abs' is ambiguous, supported type conversions allow multiple variants to match

This is due to -10.2f being treated as double, and then they are eligible for type conversions to int and float and hence the ambiguity


Affects: 3.1.1

Attachments:

Issue Links:

@spring-projects-issues
Copy link
Collaborator Author

Satyapal Reddy commented

I have a potential fix for this and wondering if I should go github route to submit my fix. We are releasing our product in next two months and wondering if we could this fix.

Thanks

@spring-projects-issues
Copy link
Collaborator Author

Chris Beams commented

Hi Satya,

Please do go ahead with a pull request per the contributor guidelines, and I'll follow up from there. Thanks!

@spring-projects-issues
Copy link
Collaborator Author

Satyapal Reddy commented

I made a pull request : #114

@spring-projects-issues
Copy link
Collaborator Author

Chris Beams commented

@Andy (added as watcher), you might want to take a look at this pull request and comment: #114

@spring-projects-issues
Copy link
Collaborator Author

Satyapal Reddy commented

Thanks for the comments on the pull request Andy.

We currently use 3.1.1 of spring framework. Is there any possibility of backporting this fix to 3.1.x?

@spring-projects-issues
Copy link
Collaborator Author

Satyapal Reddy commented

Hi Chris,

Any chance this can make into 3.1.3 ?

Satya

@spring-projects-issues
Copy link
Collaborator Author

Chris Beams commented

Hi Satya, yes, I've just scheduled this for 3.1.3.

@spring-projects-issues
Copy link
Collaborator Author

Chris Beams commented

3.2 RC1 (master):

commit be8f23d75658a8b728912b644c138407d4914f8b
Author: Satyapal Reddy <satyapal.reddy@emc.com>
Commit: Chris Beams <cbeams@vmware.com>

    Add SpEL support for float literals
    
    This change ensures that SpEL expressions involving floats are
    supported natively as opposed to the previous behavior which required
    conversion to double, leading to potential downstream conversion
    ambiguities.
    
    Issue: SPR-9486

3.1.3 (3.1.x):

commit a94677e7b6d6c6f506a7ac06d9958cb780d42fbb
Author: Satyapal Reddy <satyapal.reddy@emc.com>
Commit: Chris Beams <cbeams@vmware.com>

    Add SpEL support for float literals
    
    This change ensures that SpEL expressions involving floats are
    supported natively as opposed to the previous behavior which required
    conversion to double, leading to potential downstream conversion
    ambiguities.
    
    Issue: SPR-9486
    Backport-Commit: be8f23d75658a8b728912b644c138407d4914f8b

Update: several related commits followed those shown above in order to catch a couple failing tests. git log --grep SPR-9486 on master or 3.1.x to see everything.

@spring-projects-issues spring-projects-issues added type: enhancement A general enhancement in: core Issues in core modules (aop, beans, core, context, expression) labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 3.1.3 milestone Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

1 participant