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

NPE from MrBean when get() or set() is though as property #42

Closed
TuomasKiviaho opened this issue Feb 9, 2018 · 2 comments
Closed

NPE from MrBean when get() or set() is though as property #42

TuomasKiviaho opened this issue Feb 9, 2018 · 2 comments
Milestone

Comments

@TuomasKiviaho
Copy link

TuomasKiviaho commented Feb 9, 2018

java.lang.StringIndexOutOfBoundsException: String index out of range: 0
	at java.lang.String.charAt(String.java:658)
	at com.fasterxml.jackson.module.mrbean.BeanBuilder.decap(BeanBuilder.java:350)
	at com.fasterxml.jackson.module.mrbean.BeanBuilder.getPropertyName(BeanBuilder.java:192)
	at com.fasterxml.jackson.module.mrbean.BeanBuilder.addGetter(BeanBuilder.java:209)
	at com.fasterxml.jackson.module.mrbean.BeanBuilder.implement(BeanBuilder.java:87)

I'm getting an NPE from decap function that assumes strings to be non-empty as property names should be. The addGetter (and addSetter) should check that methodName is either more than 3 or 2 chars long depending on the prefix so that cases like introducing a java.util.function.Supplier also work

                String methodName = m.getName();
                int argCount = m.getParameterTypes().length;
                if (argCount == 0) { // getter?
                    if (methodName.startsWith("get") || methodName.startsWith("is") && returnsBoolean(m)) {
                        addGetter(ctxt, m);
                        continue;
                    }
                } else if (argCount == 1 && methodName.startsWith("set")) {
                    addSetter(ctxt, m);
                    continue;
                }
@cowtowncoder
Copy link
Member

@TuomasKiviaho Thank you for reporting this.

@cowtowncoder cowtowncoder changed the title NPE from MrBean when get or set is though as property NPE from MrBean when get() or set() is though as property Feb 13, 2018
@cowtowncoder cowtowncoder added this to the 2.9.5 milestone Feb 13, 2018
@cowtowncoder
Copy link
Member

Fixed for 2.9.5 (plus added in 2.8, if there's ever micro-patch for this repo -- branch is otherwise closed).

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

No branches or pull requests

2 participants