Skip to content
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
This repository was archived by the owner on Feb 26, 2023. It is now read-only.

IndexOutOfBoundException when using method level injection with no parameter #1795

@dodgex

Description

@dodgex

as reported here #1509 (comment)

When using an injection annotation on a method with 0 parameters the validation step throws an IndexOutOfBoundException.

the reason is that currently the full valdiation has to run and while the InjectHelper validates the parameter count and already have invalidated the annotation if it has 0 parameters lots of the annotaion handler do some additional changes that require the method parameter. the attempt to get a hand on this (not given) parameter results in this exeption.

i think we have to force stop the handler specific validation if the injectHelper already invalidated the annotation usage.

currently i have 3 ideas

// Option 1: return true/false from injecthelper.valid and return based on that value
if(!injectHelper.validate(OptionsMenuItem.class, element, validation)) {
  return;
}
// Option 2: check validation.isValid() and return based on that value
injectHelper.validate(OptionsMenuItem.class, element, validation);
if(!validation.isValid()) {
  return;
}

and without a sample Option 3: throw some kind of exception in injectHelper.validate() that is handled where *handler*.validate() is called.

while i like the option 3 for not needing a change in the handler i do not like the fact of using Exceptions for process/flow control.

I'm not sure about what i'd prefer of the other 2 options.

@WonderCsabo what option would you prefer? or do you have another idea?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions