Dariusz Hudziak created GROOVY-9287:
---------------------------------------

             Summary: @Delegate( exclude ) option is ignored
                 Key: GROOVY-9287
                 URL: https://issues.apache.org/jira/browse/GROOVY-9287
             Project: Groovy
          Issue Type: Bug
          Components: groovy-runtime
    Affects Versions: 2.5.4
         Environment: gradle plugin project, built with gradle 5.6.2,  test 
source using spock-1.3 with
groovy-2.5.4
            Reporter: Dariusz Hudziak


It seems to me that @Delegate annotation is broken with regard to it's exclude 
property:

Consider the following spock test

 

{color:#000043}class {color}WMap {
  String {color:#660e7a}name{color};
  {color:#808000}@Delegate{color}( excludes = {color:#008000}"name,a" {color})
  Map<String,String> {color:#660e7a}data{color};
 
  WMap(String name, Map<String, String> data) {
    {color:#000043}this{color}.{color:#660e7a}name {color}= name
    {color:#000043}this{color}.{color:#660e7a}data {color}= data
  }
}
{color:#000043}def {color}{color:#008000}'Test WMap properties'{color}() {
  given:
   {color:#000043}def {color}map = {color:#000043}new 
{color}WMap({color:#008000}'example'{color},[{color:#008000}'a'{color}:{color:#008000}'valA'{color},{color:#008000}b{color}:{color:#008000}'valB'{color},{color:#008000}'name'{color}:{color:#008000}'wierd'{color}])
  expect:
   map.{color:#008000}name {color}== {color:#008000}'example' 
{color}{color:#808080}// fail it's "wierd"
{color}   map.{color:#008000}a {color}== {color:#008000}'valA' 
{color}{color:#808080}// but what about exclude = a ?
{color}}

 

In the above example we see a class that is composed with map object. Despite 
having 

regurral name property,  lookups for this property end up in the target map. It 
is stated in documentation that only functions existing on delegate target java 
type are delegated ( not any GroovyObject functions ) but it seems that the 
dynamic property for each key functionallity works on the WMap  where it should 
not.

 

The fact that it works is no big deal,  but only if the exclude works - but as 
we can see the

exclude is ignored  and more over properties are covered which should be avoided

 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to