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

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?

Activity

  1. dodgex commented on Jun 10, 2016

    @dodgex
    MemberAuthor

    also while checking this i had the idea to catch exceptions thrown by validate (and maybe process) and while still logging them do not "crash" but add some kine of invalidation for this exception like we were not able to validate/process this annotation see log for details. you know what i mean?

  2. WonderCsabo commented on Jun 12, 2016

    @WonderCsabo
    Member

    Option one is shorter, but we use option two in the codebase. Maybe we would do that for the sake of consistency.

  3. dodgex commented on Jun 13, 2016

    @dodgex
    MemberAuthor

    Okay. Then I'll try to fix this issue asap. :)

  4. added a commit that references this issue on Jul 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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