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

Unable to add more than two extensions with unknown orders to a custom resource #91

Closed
andyhuang91 opened this Issue Jan 19, 2015 · 0 comments

Comments

Projects
None yet
1 participant
@andyhuang91

andyhuang91 commented Jan 19, 2015

When using the @child annotation on a custom extension of a resource, if the order field is left unspecified, then it defaults to ORDER_UNKNOWN = -1. ModelScanner reads in all of the order fields in the annotations and checks to make sure that all values for order are unique. If the order is unknown (set to the default value), the following code is run in ModelScanner

  /*
   * Anything that's marked as unknown is given a new ID that is <0 so that it doesn't conflict wityh any
   * given IDs and can be figured out later
   */
  while (order == Child.ORDER_UNKNOWN && orderMap.containsKey(order)) {
    order--;
  }

The following exception is thrown whenever I declare more than two extensions:

  if (orderMap.containsKey(order)) {
    throw new ConfigurationException("Detected duplicate field order '" + childAnnotation.order() + "' for element named '" + elementName + "' in type '" + theClass.getCanonicalName() + "'");
  }

I believe that the code is supposed to be

  if (order == Child.ORDER_UNKNOWN)
    while (orderMap.containsKey(order)) {
      order--;
    }
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment