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

Ambiguous getter/setter causes ReflectionException even when the property is not accessed #1201

Closed
rumatoest opened this issue Mar 7, 2018 · 1 comment
Assignees
Labels
Milestone

Comments

@rumatoest
Copy link

@rumatoest rumatoest commented Mar 7, 2018

MyBatis version

3.4.x at least

Steps to reproduce

interface UnifiedDto {
    boolean isManager();
}

class NewDto implements UnifiedDto {
    // Nothing special here
}

class OldDepreatedDto implements UnifiedDto {
    // the main feature
    public Manager getManager() {
    }
}

interface SomeMapper {
    int doUpdate(UnifiedDto record);
}

// NOTE THAT IN SomeMapper.XML we do not do any calls to getManager/isManager

Expected result

Should work because we pass Dto object by common interface.

Actual result

Result is really unexpected.

Even if we do not use manager property in mapper XML everything broke when we pass OldDepreatedDto instance to mapper, but works with NewDto instance.

Issue roots in Reflector witch throws exception when detects isManager and getManager methos.

IMHO it is wrong because we pass object by interface UnifiedDto which does not have getManager method.

P.S. Plus even if it was found why you are throwing an exception instead of ignoring this field. Just print debug message that you throwing away manager property and continue to work. There can be many getters in POJO that we are not using in SQL queries.

harawata added a commit to harawata/mybatis-3 that referenced this issue Aug 11, 2019
…nvoked

Lower impact fix for mybatis#1201 ,
Unlike mybatis#1201, this version throws exception only when the ambiguous setter/getter is actually invoked.
harawata added a commit to harawata/mybatis-3 that referenced this issue Aug 11, 2019
…nvoked

Lower impact fix for mybatis#1201 ,
Unlike mybatis#1335 , this version throws exception only when the ambiguous setter/getter is actually invoked.
@harawata harawata changed the title Implicit Reflector issue Ambiguous getter/setter causes ReflectionException even when the property is not accessed Aug 15, 2019
@harawata harawata self-assigned this Aug 15, 2019
@harawata harawata added this to the 3.5.3 milestone Aug 15, 2019
@harawata

This comment has been minimized.

Copy link
Member

@harawata harawata commented Aug 15, 2019

@rumatoest ,

This should be fixed in the latest 3.5.3-SNAPSHOT.
Please let us know if you find any issue.
Thank you for your report!

@harawata harawata closed this Aug 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.