diff options
author | Dan Timoney <dtimoney@att.com> | 2023-01-31 08:15:34 -0500 |
---|---|---|
committer | Dan Timoney <dtimoney@att.com> | 2023-02-07 10:24:42 -0500 |
commit | 72aef3a6324c78a62d0eff65217d4861440841f5 (patch) | |
tree | 7a208d5d4630a046e05768e004956c4c9cffa253 /adaptors/aai-service | |
parent | 8393d347d303d70e4ff4c7c91b7454467545cab3 (diff) |
Fix Java 17 jUnit errors
Add explicit lombok dependency to resolve compile error when compiling
under java 17
Fixed code issues in jUnit tests due to restrictions on reflection
in Java 17, which disallow jUnit from setting system properties
or environment variables.
Issue-ID: CCSDK-3813
Signed-off-by: Dan Timoney <dtimoney@att.com>
Change-Id: I278ee869d2ce0568b29ecc29c37d00d7fce757a8
Diffstat (limited to 'adaptors/aai-service')
2 files changed, 7 insertions, 2 deletions
diff --git a/adaptors/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIClientRESTExecutor.java b/adaptors/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIClientRESTExecutor.java index 3ededcc54..6083e89ba 100755 --- a/adaptors/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIClientRESTExecutor.java +++ b/adaptors/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIClientRESTExecutor.java @@ -31,6 +31,7 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.lang.reflect.Field; +import java.lang.reflect.InaccessibleObjectException; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Modifier; @@ -173,6 +174,7 @@ public class AAIClientRESTExecutor implements AAIExecutorInterface { } } + /** This does not work in Java 17 try { Field methodsField = HttpURLConnection.class.getDeclaredField("methods"); methodsField.setAccessible(true); @@ -184,7 +186,7 @@ public class AAIClientRESTExecutor implements AAIExecutorInterface { // remove the "final" modifier modifiersField.setInt(methodsField, methodsField.getModifiers() & ~Modifier.FINAL); - /* valid HTTP methods */ + // valid HTTP methods String[] methods = { "GET", "POST", "HEAD", "OPTIONS", "PUT", "DELETE", "TRACE", "PATCH" }; @@ -194,6 +196,7 @@ public class AAIClientRESTExecutor implements AAIExecutorInterface { } catch (SecurityException | IllegalArgumentException | IllegalAccessException | NoSuchFieldException e) { LOG.warn("Adding PATCH method", e); } + **/ LOG.info("AAIResource.ctor initialized."); } diff --git a/adaptors/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIService.java b/adaptors/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIService.java index 14206288d..f69020f75 100755 --- a/adaptors/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIService.java +++ b/adaptors/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIService.java @@ -314,6 +314,7 @@ public class AAIService extends AAIDeclarations implements AAIClient, SvcLogicRe LOG.info("AAIResource.ctor initialized."); + /* Not permitted in Java 17 try { Field methodsField = HttpURLConnection.class.getDeclaredField("methods"); methodsField.setAccessible(true); @@ -325,7 +326,7 @@ public class AAIService extends AAIDeclarations implements AAIClient, SvcLogicRe // remove the "final" modifier modifiersField.setInt(methodsField, methodsField.getModifiers() & ~Modifier.FINAL); - /* valid HTTP methods */ + // valid HTTP methods String[] methods = { "GET", "POST", "HEAD", "OPTIONS", "PUT", "DELETE", "TRACE", "PATCH" }; @@ -335,6 +336,7 @@ public class AAIService extends AAIDeclarations implements AAIClient, SvcLogicRe } catch (SecurityException | IllegalArgumentException | IllegalAccessException | NoSuchFieldException e) { LOG.error("Exception occured", e); } + */ } |