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

The difference between Ognl 3.1.16 and 3.2.10 #1524

Closed
abel533 opened this issue Apr 16, 2019 · 4 comments
Closed

The difference between Ognl 3.1.16 and 3.2.10 #1524

abel533 opened this issue Apr 16, 2019 · 4 comments
Labels

Comments

@abel533
Copy link
Contributor

abel533 commented Apr 16, 2019

MyBatis version

3.5.0+

3.4.6 use ognl 3.1.16,and 3.5.0+ use ognl 3.2.10.

in ognl 3.1.16, DefaultClassResolver find class method below:

	public Class classForName(String className, Map context) throws ClassNotFoundException
	{
	    Class       result = null;

        if ((result = (Class)classes.get(className)) == null) {
    		try {
    		    result = Class.forName(className);
    		} catch (ClassNotFoundException ex) {
    			if (className.indexOf('.') == -1) {
    			    result = Class.forName("java.lang." + className);
        			classes.put("java.lang." + className, result);
        		}
    		}
			classes.put(className, result);
    	}
	    return result;
	}

in ognl 3.2.10:

    public Class classForName(String className, Map context) throws ClassNotFoundException
    {
        Class result = classes.get(className);
        if (result != null) {
            return result;
        }
        result = (className.indexOf('.') == -1) ? toClassForName("java.lang." + className) : toClassForName(className);
        classes.put(className, result);
        return result;
    }

    protected Class toClassForName(String className) throws ClassNotFoundException {
        return Class.forName(className);
    }

When using a class without a package name, an exception that does not find java.lang.XX appears.

Recommendation: Do not use an empty package name.

@harawata
Copy link
Member

Thank you for the info, @abel533 !
Just to clarify, what is the goal of this issue?
Do you propose to use OGNL 3.1.x in MyBatis 3.5.x?

@ApplePedlar ,
There is no 4.0 release so far (their download page says 'coming soon' since 2013 or so 😁), but we will consider it when it's released, of course!

@harawata
Copy link
Member

harawata commented Jun 8, 2019

We probably won't downgrade OGNL version in 3.5.x.
Closing as 'won't fix'.

@harawata
Copy link
Member

harawata commented Dec 23, 2019

Just FYI, this should be fixed in the latest 3.5.4-SNAPSHOT via #1768 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants