[prev in list] [next in list] [prev in thread] [next in thread] 

List:       groovy-user
Subject:    [groovy-user] bug in FactoryBuilderSupport
From:       "Skeptic ." <skeptic2000 () hotmail ! com>
Date:       2014-01-31 19:36:47
Message-ID: BLU175-W2BFBAF7DBF0A9F076D452BEAE0 () phx ! gbl
[Download RAW message or body]

Hi,
When a explicit method is called in nested factories with the wrong name / arguments, \
the error is not correctly reported abd the methodMissingDelegate is not called. Here \
is a builder and a script that show the problem. class TestBuilder extends \
FactoryBuilderSupport {  TestBuilder() {        super(true)    }
    def registerAll() {        registerFactory('a', new AFactory())        \
registerFactory('b', new BFactory())        registerExplicitMethod('c', this.&test)   \
}

    class AFactory extends AbstractFactory {
        @Override        public Object newInstance(FactoryBuilderSupport builder, \
Object name, Object value, Map attributes) throws InstantiationException, \
IllegalAccessException {            true        }    }  class BFactory extends \
AbstractFactory {  @Override        public Object newInstance(FactoryBuilderSupport \
builder, Object name, Object value, Map attributes) throws InstantiationException, \
IllegalAccessException {            true        }    }  protected Integer \
test(Integer i1, Integer i2) {        i1 + i2    }} \
///////////////////////////////////////////////////////// def tb = new TestBuilder()
tb.a() {
    b() {        c(3, "4")  // or it could have been ct(3, 4) or any other typo.    \
}}

 		 	   		  


[Attachment #3 (text/html)]

<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>Hi,<div><br></div><div>When a explicit method \
is called in nested factories with the wrong name / arguments, the error is not \
correctly reported abd the methodMissingDelegate is not \
called.</div><div><br></div><div><span style="font-size: 12pt;">Here is a builder and \
a script that show the problem.</span></div><div><br></div><div><div>class \
TestBuilder extends FactoryBuilderSupport {</div><div><br></div><div>&nbsp; &nbsp; \
TestBuilder() {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; super(true)</div><div>&nbsp; \
&nbsp; }</div><div><br></div><div>&nbsp; &nbsp; def registerAll() {</div><div>&nbsp; \
&nbsp; &nbsp; &nbsp; registerFactory('a', new AFactory())</div><div>&nbsp; &nbsp; \
&nbsp; &nbsp; registerFactory('b', new BFactory())</div><div>&nbsp; &nbsp; &nbsp; \
&nbsp; registerExplicitMethod('c', this.&amp;test)</div><div>&nbsp; &nbsp; \
}</div><div><br></div><div><br></div><div>&nbsp; &nbsp; class AFactory extends \
AbstractFactory {</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; \
@Override</div><div>&nbsp; &nbsp; &nbsp; &nbsp; public Object \
newInstance(FactoryBuilderSupport builder, Object name, Object value, Map attributes) \
throws InstantiationException, IllegalAccessException {</div><div>&nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; true</div><div>&nbsp; &nbsp; &nbsp; &nbsp; \
}</div><div>&nbsp; &nbsp; }</div><div><br></div><div>&nbsp; &nbsp; class BFactory \
extends AbstractFactory {</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; \
@Override</div><div>&nbsp; &nbsp; &nbsp; &nbsp; public Object \
newInstance(FactoryBuilderSupport builder, Object name, Object value, Map attributes) \
throws InstantiationException, IllegalAccessException {</div><div>&nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; true</div><div>&nbsp; &nbsp; &nbsp; &nbsp; \
}</div><div>&nbsp; &nbsp; }</div><div><br></div><div>&nbsp; &nbsp; protected Integer \
test(Integer i1, Integer i2) {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; i1 + \
i2</div><div>&nbsp; &nbsp; \
}</div><div>}</div></div><div><br></div><div>/////////////////////////////////////////////////////////</div><div><br></div><div><div>def \
tb = new TestBuilder()</div><div><br></div><div>tb.a() \
{</div><div><br></div><div>&nbsp; &nbsp; b() {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; \
c(3, "4") &nbsp;// or it could have been ct(3, 4) or any other typo.</div><div>&nbsp; \
&nbsp; }</div><div>}</div></div><div><br></div><div><br></div> 		 	   		  \
</div></body> </html>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic