[java-opensaml] branch master updated: IDP-1397 fix deprecated warnings

Daniel Fisher dfisher at vt.edu
Fri Feb 21 15:48:17 EST 2020


This is an automated email from the git hooks/post-receive script.

dfisher pushed a commit to branch master
in repository java-opensaml.

View the commit online:
http://git.shibboleth.net/view/?p=java-opensaml.git;a=commit;h=e27977ad5abb4b591132a3c1b7b6746aeb221f0e

The following commit(s) were added to refs/heads/master by this push:
       new  e27977a   IDP-1397 fix deprecated warnings
e27977a is described below

commit e27977ad5abb4b591132a3c1b7b6746aeb221f0e
Author: Daniel Fisher <dfisher at vt.edu>
AuthorDate: Fri Feb 21 15:46:34 2020 -0500

    IDP-1397 fix deprecated warnings
    
    Suppress unchecked warning for cast in AbstractMapBackedStorageService.
    Use new canAccess and trySetAccessible methods instead of isAccessible.
    Note that these methods were introduced with JPMS which would indicate there is someway in which using modules with our code could break reflection accessibility.
---
 .../java/org/opensaml/storage/AbstractMapBackedStorageService.java   | 1 +
 .../main/java/org/opensaml/storage/annotation/AnnotationSupport.java | 5 ++---
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/opensaml-storage-api/src/main/java/org/opensaml/storage/AbstractMapBackedStorageService.java b/opensaml-storage-api/src/main/java/org/opensaml/storage/AbstractMapBackedStorageService.java
index 8c026f5..48dc494 100644
--- a/opensaml-storage-api/src/main/java/org/opensaml/storage/AbstractMapBackedStorageService.java
+++ b/opensaml-storage-api/src/main/java/org/opensaml/storage/AbstractMapBackedStorageService.java
@@ -292,6 +292,7 @@ public abstract class AbstractMapBackedStorageService extends AbstractStorageSer
      * @return  a pair consisting of the version of the record read back, if any, and the record itself
      * @throws IOException  if errors occur in the read process 
      */
+    @SuppressWarnings("unchecked")
     @Nonnull protected <T> Pair<Long,StorageRecord<T>> readImpl(@Nonnull @NotEmpty final String context,
             @Nonnull @NotEmpty final String key, @Nullable final Long version) throws IOException {
 
diff --git a/opensaml-storage-api/src/main/java/org/opensaml/storage/annotation/AnnotationSupport.java b/opensaml-storage-api/src/main/java/org/opensaml/storage/annotation/AnnotationSupport.java
index 72b2a80..6d7dc7f 100644
--- a/opensaml-storage-api/src/main/java/org/opensaml/storage/annotation/AnnotationSupport.java
+++ b/opensaml-storage-api/src/main/java/org/opensaml/storage/annotation/AnnotationSupport.java
@@ -291,9 +291,8 @@ public final class AnnotationSupport {
         if (field == null) {
             try {
                 field = targetClass.getDeclaredField(fieldName);
-                if (!field.isAccessible()) {
-                    // Try to make it accessible
-                    field.setAccessible(true);
+                if (!(field.canAccess(target) || field.trySetAccessible())) {
+                  throw new IllegalStateException("Field " + field + " is not accessible and cannot be mutated");
                 }
                 FIELD_CACHE.put(key, field);
             } catch (final NoSuchFieldException e) {

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list