You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (Jira)" <ji...@apache.org> on 2020/02/03 13:10:00 UTC

[jira] [Commented] (GROOVY-9369) Unable to distinguish foo.x and foo.getProperty("x") in call interceptor

    [ https://issues.apache.org/jira/browse/GROOVY-9369?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17028921#comment-17028921 ] 

Paul King commented on GROOVY-9369:
-----------------------------------

Marking as blocker temporarily so we investigate and decide a course of action before 3.0.0 final.

> Unable to distinguish foo.x and foo.getProperty("x") in call interceptor
> ------------------------------------------------------------------------
>
>                 Key: GROOVY-9369
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9369
>             Project: Groovy
>          Issue Type: Task
>          Components: groovy-runtime
>    Affects Versions: 3.0.0-rc-2, 3.0.0-rc-3
>            Reporter: Marcin Zajaczkowski
>            Priority: Blocker
>             Fix For: 3.x
>
>
> TL;TR. It is problematic in Groovy 3 to distinguish go.x and go.getProperty("x") in a call (at the level of an interceptor for a mocking system)?
> A ticket to track problem raised using the [mailing list|https://mail-archives.apache.org/mod_mbox/groovy-dev/202001.mbox/%3c54d78589-67e2-7c92-6512-2407829609d6@wp.pl%3e] . Quoted original concerns:
> {quote}Working on the Spock adjustment to Groovy 3 I spotted that Groovy 3
>  started for a property access go.x (go - some GroovyObject instance with
>  a field "x") to call go.getProperty("x") instead of go.getX() directly
>  (as it took place in Groovy 2). This broke tests for mocking with a
>  property call (getX() is stubbed, but go.x is called) and forced me to
>  detect getProperty("x") calls in a mock interceptor - to analyze deeper
>  and check which method (here getter) is being called and if has been
>  stubbed.
> However, in addition, it should be possible to just stub direct
>  go.getProperty("x") calls [1]. To do that, currently, I have to analyze
>  a stack trace to detect groovy.lang.GroovyObject$getProperty.call() at
>  the position -3 [2] (for direct go.getProperty("x") calls) and deeper
>  process only the other calls (go.x). It seems to work, but it's quite
>  ugly and fragile. I wonder, how to reliably differentiate those two
>  types of calls?
>  [1] -[ https://github.com/spockframework/spock/blob/1dd24a2251afe3151e04b50af8afb6285b236c76/spock-specs/src/test/groovy/org/spockframework/smoke/mock/JavaMocksForGroovyClasses.groovy#L75-L81|https://github.com/spockframework/spock/blob/1dd24a2251afe3151e04b50af8afb6285b236c76/spock-specs/src/test/groovy/org/spockframework/smoke/mock/JavaMocksForGroovyClasses.groovy#L75-L81]
>  [2] -[ https://github.com/spockframework/spock/commit/1dd24a2251afe3151e04b50af8afb6285b236c76|https://github.com/spockframework/spock/commit/1dd24a2251afe3151e04b50af8afb6285b236c76]
> {quote}



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