[weld-issues] [JBoss JIRA] Commented: (WELD-469) Exception in normal mode for incompletly annotated custom scopes.

Wolfgang Frech (JIRA) jira-events at lists.jboss.org
Mon Mar 15 05:01:37 EDT 2010


    [ https://jira.jboss.org/jira/browse/WELD-469?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12519833#action_12519833 ] 

Wolfgang Frech commented on WELD-469:
-------------------------------------

I wrote this from memory, so here is the more detailed report:


1) JSR-299 as of 10 November 2009 specifies that a scope type is, among other Annotations, marked as @Target({METHOD)} (2.4.2, page 15)

2) JSR-299 mandates a definition error to be detected at container initialization time, and that the container must abort initialization. (2.8, p. 20)

3) A scope type definition without method target violates the specification, and a bean using this invalid scope type as well, thus the container must abort initialization.  The definition of  definition errors as "violates the rules of this specification" is rather broad, but looks reasonable to me.

4) JSR-299 does not specify an exception with any particular message, but I would think that "abort" implies that.

5) JSR-299 permits a "non-portable mode for development", where the container may try to initialize even with definition errors present. Again, the specification is not explicit about modes. I would expect that the container is in normal mode if no development mode is configured.

6) Weld 1.0.1 ScopeModel.initValid tests for Target and the expected values, including METHOD. If missing, the scope type is invalid.

7) Weld logs a _debug_ message, but does not throw an exception. Debug messages are not visible in normal development configuration.

8) BeanManager.getReference creates a client proxy only if isProxyRequired, that is if the scope type is normal, that is if it is valid. No exception here or logging either. 

So I would suggest:
a) throw an exception for invalid scope types at initialization time, with the message that is now in the debug log.
b) define a development mode (with a config switch for it), log the message as a _warning_ and complete initalization, just as now.
c) develop an Eclipse plugin that detects this problem and gives a Quick Fix "add missing METHOD to @Target"; well, maybe not for this, but in general for common definition errors.

> Exception in normal mode for incompletly annotated custom scopes.
> -----------------------------------------------------------------
>
>                 Key: WELD-469
>                 URL: https://jira.jboss.org/jira/browse/WELD-469
>             Project: Weld
>          Issue Type: Bug
>    Affects Versions: 1.0.1.Final
>         Environment: n/a
>            Reporter: Wolfgang Frech
>
> If a custom scope is incomplete, say without the target annotation for field and type, but without method, Weld now
> - logs a warning
> - uses the context for that scope
> - marks the scope as invalid
> - returns only Java, not ClientProxy refs for Beans.
> According to the spec,the container must detect   the missing annotation.
> It should not complete the initialization.
> In addition to that behavior, it may treat it on a best-effort basis, but only in development mode.
> In normal mode, the container should throw an exception that cannot be missed.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the weld-issues mailing list