Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-64390

org.acegisecurity.util.FieldUtils.setProtectedFieldValue is not compatable with the old code

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • core
    • 2.271

      the previous implementaion of `FieldUtils.setProtectedFieldValue` worked for final as well as protected methods.

      this is not the case for the new code and it fails with

      ```
      java.lang.IllegalAccessException: Can not set final java.lang.ClassLoader field hudson.PluginManager.uberClassLoader to org.powermock.core.classloader.javassist.JavassistMockClassLoader
      at sun.reflect.UnsafeFieldAccessorImpl.throwFinalFieldIllegalAccessException(UnsafeFieldAccessorImpl.java:76)
      at sun.reflect.UnsafeFieldAccessorImpl.throwFinalFieldIllegalAccessException(UnsafeFieldAccessorImpl.java:80)
      at sun.reflect.UnsafeQualifiedObjectFieldAccessorImpl.set(UnsafeQualifiedObjectFieldAccessorImpl.java:79)
      at java.lang.reflect.Field.set(Field.java:764)
      at org.apache.commons.lang.reflect.FieldUtils.writeField(FieldUtils.java:523)
      at org.apache.commons.lang.reflect.FieldUtils.writeField(FieldUtils.java:500)
      at org.apache.commons.lang.reflect.FieldUtils.writeField(FieldUtils.java:560)
      at org.acegisecurity.util.FieldUtils.setProtectedFieldValue(FieldUtils.java:43)
      ```

      the code should be adapted to work with final classes.

      Currently only observed in test code - but may as well fix it before it is observed in production code.

          [JENKINS-64390] org.acegisecurity.util.FieldUtils.setProtectedFieldValue is not compatable with the old code

          James Nord created issue -
          James Nord made changes -
          Status Original: Open [ 1 ] New: In Progress [ 3 ]
          James Nord made changes -
          Status Original: In Progress [ 3 ] New: In Review [ 10005 ]
          Jesse Glick made changes -
          Remote Link New: This issue links to "jenkins #5105 (Web Link)" [ 26355 ]
          Mark Waite made changes -
          Resolution New: Fixed [ 1 ]
          Status Original: In Review [ 10005 ] New: Resolved [ 5 ]
          Jesse Glick made changes -
          Status Original: Resolved [ 5 ] New: Fixed but Unreleased [ 10203 ]
          Mark Waite made changes -
          Released As New: 2.271
          Status Original: Fixed but Unreleased [ 10203 ] New: Resolved [ 5 ]
          Josh Soref made changes -
          Description Original: the previous implementaion of `FiledUtils.setProtectedFieldValue` worked for final as well as protected methods.

          this is not the case for the new code and it fails with

          ```
          java.lang.IllegalAccessException: Can not set final java.lang.ClassLoader field hudson.PluginManager.uberClassLoader to org.powermock.core.classloader.javassist.JavassistMockClassLoader
                  at sun.reflect.UnsafeFieldAccessorImpl.throwFinalFieldIllegalAccessException(UnsafeFieldAccessorImpl.java:76)
                  at sun.reflect.UnsafeFieldAccessorImpl.throwFinalFieldIllegalAccessException(UnsafeFieldAccessorImpl.java:80)
                  at sun.reflect.UnsafeQualifiedObjectFieldAccessorImpl.set(UnsafeQualifiedObjectFieldAccessorImpl.java:79)
                  at java.lang.reflect.Field.set(Field.java:764)
                  at org.apache.commons.lang.reflect.FieldUtils.writeField(FieldUtils.java:523)
                  at org.apache.commons.lang.reflect.FieldUtils.writeField(FieldUtils.java:500)
                  at org.apache.commons.lang.reflect.FieldUtils.writeField(FieldUtils.java:560)
                  at org.acegisecurity.util.FieldUtils.setProtectedFieldValue(FieldUtils.java:43)
          ```

          the code should be adapted to work with final classes.

          Currently only observed in test code - but may as well fix it before it is observed in production code.
          New: the previous implementaion of `FieldUtils.setProtectedFieldValue` worked for final as well as protected methods.

          this is not the case for the new code and it fails with

          ```
           java.lang.IllegalAccessException: Can not set final java.lang.ClassLoader field hudson.PluginManager.uberClassLoader to org.powermock.core.classloader.javassist.JavassistMockClassLoader
           at sun.reflect.UnsafeFieldAccessorImpl.throwFinalFieldIllegalAccessException(UnsafeFieldAccessorImpl.java:76)
           at sun.reflect.UnsafeFieldAccessorImpl.throwFinalFieldIllegalAccessException(UnsafeFieldAccessorImpl.java:80)
           at sun.reflect.UnsafeQualifiedObjectFieldAccessorImpl.set(UnsafeQualifiedObjectFieldAccessorImpl.java:79)
           at java.lang.reflect.Field.set(Field.java:764)
           at org.apache.commons.lang.reflect.FieldUtils.writeField(FieldUtils.java:523)
           at org.apache.commons.lang.reflect.FieldUtils.writeField(FieldUtils.java:500)
           at org.apache.commons.lang.reflect.FieldUtils.writeField(FieldUtils.java:560)
           at org.acegisecurity.util.FieldUtils.setProtectedFieldValue(FieldUtils.java:43)
           ```

          the code should be adapted to work with final classes.

          Currently only observed in test code - but may as well fix it before it is observed in production code.

            teilo James Nord
            teilo James Nord
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: