commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andre Diermann (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (LANG-965) FieldUtils methods leak accessible flags
Date Wed, 27 Aug 2014 18:07:59 GMT

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

Andre Diermann commented on LANG-965:
-------------------------------------

Hello Benedikt,

many thanks for your remarks.

bq. a new issue for this small change is a bit overkill. Just add it to your patch.

Done.

bq. yes, but correctness of readField() is asserted by individual unit tests for that method,
so I think it's okay to use it in the test for writeField() if this makes the test code easier
to understand.

Done. It's really more readable like this.

bq. So the idea is use getField with forceAccess = false to retrieve the field. This will
return the field, even if it is not accessible. After that you can simply call the other writeField()
and pass the forceAccess parameter into it. That method in turn will handle restoring of the
accessibility flag for you.

I changed this as well and the code looked really nice ;-) ... but unfortunately it broke
the tests, because this changed the required behavior of the method :-(

"forceAccess" is a little bit misleading here, because it does not mean "always assure setAccessible(true)"
is called, it rather means "break the scope" or more precisely "also search superclasses for
this field". So when trying to read or write a field with the proposed implementation, the
field could not be found anymore if it is specified in a superclass.

After that I investigated the code of {{FieldUtils}} more and discovered that my patch does
not cover all accessibility changes :-( It seems the accessibility is changed literally everywhere
;-) I followed a lot of paths and finally came to the conclusion that my original approach
of "use the minimum amount of code changes" is not sufficient to cope with this problem.

So I will work on a more elaborated patch. Just want to inform you that this might take a
while, because the underlying issue is more complex than I initially expected O:-)  

Best regards,
André

> FieldUtils methods leak accessible flags
> ----------------------------------------
>
>                 Key: LANG-965
>                 URL: https://issues.apache.org/jira/browse/LANG-965
>             Project: Commons Lang
>          Issue Type: Bug
>          Components: lang.reflect.*
>    Affects Versions: 3.1, 3.2.1
>         Environment: Apache Maven 3.1.1 (0728685237757ffbf44136acec0402957f723d9a; 2013-09-17
11:22:22-0400)
> Maven home: C:\Java\apache-maven-3.1.1\bin\..
> Java version: 1.7.0_51, vendor: Oracle Corporation
> Java home: C:\Program Files\Java\jdk1.7.0_51\jre
> Default locale: en_US, platform encoding: Cp1252
> OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"
>            Reporter: Gary Gregory
>            Assignee: Benedikt Ritter
>             Fix For: Review Patch
>
>         Attachments: commons-lang-965.patch
>
>
> When various FieldUtils methods are called the accessible is set to true but never reset
to false. This is side-effect should be cleaned up.
> This makes a mess of the object model which represents the class meta data.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Mime
View raw message