From 5f922375e19c2a87ec945873fd5c193a41b439de Mon Sep 17 00:00:00 2001
From: Solomon Ayalew <solxget@amazon.com>
Date: Wed, 4 Oct 2023 14:33:53 -0700
Subject: [PATCH] Upgrade to java 17

(cherry picked from commit 1586ab4dbaff2d2d1c40dadc08363aeabb8f5322)
---
 notification-core/pom.xml                     |  7 +++---
 .../auth/AuthorizationFilterTest.java         |  4 ++--
 .../AuthorizationServiceEntitlementsTest.java |  2 +-
 pom.xml                                       | 15 ++++++++++--
 .../notification-aws/build-aws/Dockerfile     |  2 +-
 .../notification-aws/build-aws/buildspec.yaml | 23 +++++++------------
 .../notification-aws/build-aws/entrypoint.sh  |  5 +---
 provider/notification-aws/pom.xml             |  2 +-
 .../aws/impl/AwsGoogleServiceAccountImpl.java |  6 ++---
 provider/notification-azure/pom.xml           |  6 +++--
 .../azure/util/GoogleServiceAccountImpl.java  |  3 +--
 .../util/GoogleServiceAccountImpTest.java     |  3 +--
 .../util/ServiceAccountClientImplTest.java    |  4 +---
 provider/notification-gc/pom.xml              |  4 ++--
 provider/notification-ibm/pom.xml             |  2 +-
 testing/notification-test-aws/pom.xml         |  2 +-
 testing/notification-test-azure/pom.xml       |  2 +-
 testing/notification-test-baremetal/pom.xml   |  2 +-
 testing/notification-test-core/pom.xml        |  2 +-
 testing/notification-test-gc/pom.xml          |  4 ++--
 testing/notification-test-ibm/pom.xml         |  2 +-
 21 files changed, 51 insertions(+), 51 deletions(-)

diff --git a/notification-core/pom.xml b/notification-core/pom.xml
index 593971887..95e15e930 100644
--- a/notification-core/pom.xml
+++ b/notification-core/pom.xml
@@ -32,7 +32,7 @@
 	</parent>
 
     <properties>
-        <java.version>8</java.version>
+        <java.version>17</java.version>
         <maven.compiler.target>${java.version}</maven.compiler.target>
         <maven.compiler.source>${java.version}</maven.compiler.source>
         <netty.version>4.1.70.Final</netty.version>
@@ -76,7 +76,7 @@
         <dependency>
             <groupId>org.projectlombok</groupId>
             <artifactId>lombok</artifactId>
-            <version>1.18.8</version>
+            <version>1.18.26</version>
             <scope>provided</scope>
         </dependency>
         <dependency>
@@ -285,7 +285,7 @@
             <plugin>
                 <groupId>org.jacoco</groupId>
                 <artifactId>jacoco-maven-plugin</artifactId>
-                <version>0.8.2</version>
+                <version>0.8.10</version>
                 <configuration>
                     <excludes>
                         <exclude>**/models/*</exclude>
@@ -316,6 +316,7 @@
             <plugin>
                 <groupId>org.jacoco</groupId>
                 <artifactId>jacoco-maven-plugin</artifactId>
+                <version>0.8.10</version>
                 <reportSets>
                     <reportSet>
                         <reports>
diff --git a/notification-core/src/test/java/org/opengroup/osdu/notification/auth/AuthorizationFilterTest.java b/notification-core/src/test/java/org/opengroup/osdu/notification/auth/AuthorizationFilterTest.java
index 5ae208b77..eb486ad35 100644
--- a/notification-core/src/test/java/org/opengroup/osdu/notification/auth/AuthorizationFilterTest.java
+++ b/notification-core/src/test/java/org/opengroup/osdu/notification/auth/AuthorizationFilterTest.java
@@ -37,8 +37,8 @@ import java.util.Map;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
diff --git a/notification-core/src/test/java/org/opengroup/osdu/notification/auth/AuthorizationServiceEntitlementsTest.java b/notification-core/src/test/java/org/opengroup/osdu/notification/auth/AuthorizationServiceEntitlementsTest.java
index 722c856aa..519170d6d 100644
--- a/notification-core/src/test/java/org/opengroup/osdu/notification/auth/AuthorizationServiceEntitlementsTest.java
+++ b/notification-core/src/test/java/org/opengroup/osdu/notification/auth/AuthorizationServiceEntitlementsTest.java
@@ -40,7 +40,7 @@ import java.util.List;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
-import static org.mockito.Matchers.any;
+import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.when;
 
 @RunWith(PowerMockRunner.class)
diff --git a/pom.xml b/pom.xml
index 176f69e16..ef0726230 100644
--- a/pom.xml
+++ b/pom.xml
@@ -22,7 +22,7 @@
 	<description>Root Notification Service project</description>
 
 	<properties>
-		<java.version>8</java.version>
+		<java.version>17</java.version>
 		<maven.compiler.target>${java.version}</maven.compiler.target>
 		<maven.compiler.source>${java.version}</maven.compiler.source>
 		<os-core-common.version>0.23.3</os-core-common.version>
@@ -104,7 +104,7 @@
 		<dependency>
 			<groupId>org.projectlombok</groupId>
 			<artifactId>lombok</artifactId>
-			<version>1.18.8</version>
+			<version>1.18.26</version>
 			<scope>provided</scope>
 		</dependency>
 	<!-- swagger dependency -->
@@ -216,6 +216,17 @@
 					</generateGitPropertiesFilename>
 				</configuration>
 			</plugin>
+         	<plugin>
+                 <groupId>org.apache.maven.plugins</groupId>
+                 <artifactId>maven-surefire-plugin</artifactId>
+                 <version>3.0.0</version>
+                 <configuration>
+                     <argLine>
+                         @{argLine} --add-opens java.base/java.util=ALL-UNNAMED
+                         --add-opens java.base/java.lang=ALL-UNNAMED
+                     </argLine>
+                 </configuration>
+             </plugin>
 		</plugins>
 	</build>
 </project>
diff --git a/provider/notification-aws/build-aws/Dockerfile b/provider/notification-aws/build-aws/Dockerfile
index 07b035a53..ad5ef0451 100644
--- a/provider/notification-aws/build-aws/Dockerfile
+++ b/provider/notification-aws/build-aws/Dockerfile
@@ -13,7 +13,7 @@
 # limitations under the License.
 
 # https://docs.spring.io/spring-boot/docs/current/reference/html/deployment.html
-FROM amazoncorretto:8
+FROM amazoncorretto:17
 
 ARG JAR_FILE=provider/notification-aws/target/*spring-boot.jar
 # Harcoding this value since Notification-core requires this variable. AWS does not use it. Might change in future
diff --git a/provider/notification-aws/build-aws/buildspec.yaml b/provider/notification-aws/build-aws/buildspec.yaml
index 623f56653..20fe43e53 100644
--- a/provider/notification-aws/build-aws/buildspec.yaml
+++ b/provider/notification-aws/build-aws/buildspec.yaml
@@ -32,11 +32,7 @@ phases:
     runtime-versions:
       java: corretto8
     commands:
-      # fix error noted here: https://github.com/yarnpkg/yarn/issues/7866
-      - curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
       - if [ $(echo $CODEBUILD_SOURCE_VERSION | grep -c  ^refs/heads.*) -eq 1 ]; then echo "Branch name found"; else echo "This build only supports branch builds" && exit 1; fi
-      - apt-get update -y -qq > /dev/null
-      - apt-get install -y maven -qq >/dev/null
       - java -version
       - mvn -version
       - mkdir -p /root/.m2
@@ -44,9 +40,6 @@ phases:
       - export AWS_ACCOUNT_ID=`aws sts get-caller-identity | grep Account | cut -d':' -f 2 | cut -d'"' -f 2`
       - export AWS_OSDU_DEV_MAVEN_AUTH_TOKEN=`aws codeartifact get-authorization-token --domain $AWS_OSDU_DEV_MAVEN_DOMAIN --domain-owner $AWS_ACCOUNT_ID --query authorizationToken --output text`
       # Install git secrets
-      #TODO temporarily adding hotfix, due to https://github.com/awslabs/git-secrets/issues/220
-      - export SAY_LOCATION=`ln -s "$(which echo)" say`
-      - export PATH="$PATH:$SAY_LOCATION"
 
       - git clone https://github.com/awslabs/git-secrets.git
       - cd git-secrets && make install && cd ..
@@ -54,7 +47,10 @@ phases:
   pre_build:
     commands:
       - echo "Logging in to Amazon ECR..."
-      - aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin ${ECR_REGISTRY} # authenticate with ECR via the AWS CLI
+      - aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin ${ECR_REGISTRY}
+      - echo "Logging into Docker Hub..."
+      - docker login -u ${DOCKER_USERNAME} -p ${DOCKER_PASSWORD}
+
   build:
     commands:
       - export REPO_NAME=${PWD##*/}
@@ -76,9 +72,9 @@ phases:
       - if [ "$GIT_SECRETS_SCAN_RESULT" = "FAILED" ]; then echo "Secrets detected!" && exit 1; fi
 
       - echo "Building primary service assemblies..."
-      - mvn -ntp -B test install -pl .,notification-core,provider/notification-aws -Ddeployment.environment=prod  
-      - mvn sonar:sonar -pl .,provider/notification-aws -Dsonar.scm.provider=git -Dsonar.login=${SONAR_USERNAME} -Dsonar.password=${SONAR_PASSWORD} -Dsonar.branch.name=${BRANCH_NAME}
-       
+      - mvn --no-transfer-progress -ntp -B test install -pl .,notification-core,provider/notification-aws -Ddeployment.environment=prod  
+      - mvn --no-transfer-progress sonar:sonar -pl .,provider/notification-aws -Dsonar.scm.provider=git -Dsonar.login=${SONAR_USERNAME} -Dsonar.password=${SONAR_PASSWORD} -Dsonar.branch.name=${BRANCH_NAME}
+  
       - echo "Building integration testing assemblies and gathering artifacts..."
       - ./testing/notification-test-aws/build-aws/prepare-dist.sh
 
@@ -86,9 +82,6 @@ phases:
       - echo "--Copying Helm Charts to ${OUTPUT_DIR:-dist}--"
       - rsync -r devops/aws/* "${OUTPUT_DIR:-dist}"
 
-      - echo "Logging into Docker Hub..."
-      - docker login -u ${DOCKER_USERNAME} -p ${DOCKER_PASSWORD}
-
       - echo "Building docker image..."
       - docker build -f provider/notification-aws/build-aws/Dockerfile -t ${ECR_IMAGE} .
       - docker tag  ${ECR_IMAGE} ${ECR_IMAGE_BRANCH_LATEST}
@@ -117,4 +110,4 @@ artifacts:
   name: ${REPO_NAME}_${BRANCH_NAME}_$(date +%F)_${CODEBUILD_BUILD_NUMBER}.zip
 cache:
   paths:
-    - "/root/.m2/**/*"
\ No newline at end of file
+    - "/root/.m2/**/*"
diff --git a/provider/notification-aws/build-aws/entrypoint.sh b/provider/notification-aws/build-aws/entrypoint.sh
index 412f71afd..c372dfb63 100755
--- a/provider/notification-aws/build-aws/entrypoint.sh
+++ b/provider/notification-aws/build-aws/entrypoint.sh
@@ -1,4 +1 @@
-
-
-
-java $JAVA_OPTS -jar /app.jar
\ No newline at end of file
+java $JAVA_OPTS --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED -jar /app.jar
diff --git a/provider/notification-aws/pom.xml b/provider/notification-aws/pom.xml
index a3d63c2d1..e7b7b2baf 100644
--- a/provider/notification-aws/pom.xml
+++ b/provider/notification-aws/pom.xml
@@ -32,7 +32,7 @@
     </parent>
 
     <properties>
-        <java.version>8</java.version>
+        <java.version>17</java.version>
         <maven.compiler.target>${java.version}</maven.compiler.target>
         <maven.compiler.source>${java.version}</maven.compiler.source>
         <aws.version>1.11.1018</aws.version>
diff --git a/provider/notification-aws/src/main/java/org/opengroup/osdu/notification/provider/aws/impl/AwsGoogleServiceAccountImpl.java b/provider/notification-aws/src/main/java/org/opengroup/osdu/notification/provider/aws/impl/AwsGoogleServiceAccountImpl.java
index e4754d9a7..09c56e5df 100644
--- a/provider/notification-aws/src/main/java/org/opengroup/osdu/notification/provider/aws/impl/AwsGoogleServiceAccountImpl.java
+++ b/provider/notification-aws/src/main/java/org/opengroup/osdu/notification/provider/aws/impl/AwsGoogleServiceAccountImpl.java
@@ -15,13 +15,13 @@ package org.opengroup.osdu.notification.provider.aws.impl;
 import org.opengroup.osdu.notification.provider.interfaces.IGoogleServiceAccount;
 import org.springframework.stereotype.Component;
 
-
 @Component
 public class AwsGoogleServiceAccountImpl implements IGoogleServiceAccount {
     @Override
-    // To do: Check if it is to be supported
     public String getIdToken(String keyString, String audience) {
-        throw new UnsupportedOperationException();
+        // TODO : Check if it is to be supported
+
+    	throw new UnsupportedOperationException();
     }
 }
 
diff --git a/provider/notification-azure/pom.xml b/provider/notification-azure/pom.xml
index 9823b3e4c..c880f5fcc 100644
--- a/provider/notification-azure/pom.xml
+++ b/provider/notification-azure/pom.xml
@@ -31,10 +31,10 @@
   </parent>
 
   <properties>
-    <java.version>8</java.version>
+    <java.version>17</java.version>
     <maven.compiler.target>${java.version}</maven.compiler.target>
     <maven.compiler.source>${java.version}</maven.compiler.source>
-    <jacoco-maven-plugin.version>0.8.2</jacoco-maven-plugin.version>
+    <jacoco-maven-plugin.version>0.8.10</jacoco-maven-plugin.version>
     <osdu.notification-core.version>0.24.0-SNAPSHOT</osdu.notification-core.version>
     <springframework.version>4.3.0.RELEASE</springframework.version>
     <reactor.netty.version>0.11.0.RELEASE</reactor.netty.version>
@@ -310,6 +310,7 @@
       <plugin>
         <groupId>org.jacoco</groupId>
         <artifactId>jacoco-maven-plugin</artifactId>
+        <version>${jacoco-maven-plugin.version}</version>
         <reportSets>
           <reportSet>
             <reports>
@@ -319,6 +320,7 @@
           </reportSet>
         </reportSets>
       </plugin>
+
     </plugins>
   </reporting>
 </project>
diff --git a/provider/notification-azure/src/main/java/org/opengroup/osdu/notification/provider/azure/util/GoogleServiceAccountImpl.java b/provider/notification-azure/src/main/java/org/opengroup/osdu/notification/provider/azure/util/GoogleServiceAccountImpl.java
index 27232c166..ab1027a55 100644
--- a/provider/notification-azure/src/main/java/org/opengroup/osdu/notification/provider/azure/util/GoogleServiceAccountImpl.java
+++ b/provider/notification-azure/src/main/java/org/opengroup/osdu/notification/provider/azure/util/GoogleServiceAccountImpl.java
@@ -16,7 +16,6 @@ package org.opengroup.osdu.notification.provider.azure.util;
 
 import org.opengroup.osdu.notification.provider.interfaces.IGoogleServiceAccount;
 import org.springframework.stereotype.Component;
-import sun.reflect.generics.reflectiveObjects.NotImplementedException;
 
 @Component
 public class GoogleServiceAccountImpl implements IGoogleServiceAccount {
@@ -25,6 +24,6 @@ public class GoogleServiceAccountImpl implements IGoogleServiceAccount {
     public String getIdToken(String keyString, String audience) {
         // TODO : Check if it is to be supported
 
-        throw new NotImplementedException();
+    	throw new UnsupportedOperationException();
     }
 }
diff --git a/provider/notification-azure/src/test/java/org/opengroup/osdu/notification/util/GoogleServiceAccountImpTest.java b/provider/notification-azure/src/test/java/org/opengroup/osdu/notification/util/GoogleServiceAccountImpTest.java
index a643fb4c4..21506e390 100644
--- a/provider/notification-azure/src/test/java/org/opengroup/osdu/notification/util/GoogleServiceAccountImpTest.java
+++ b/provider/notification-azure/src/test/java/org/opengroup/osdu/notification/util/GoogleServiceAccountImpTest.java
@@ -19,7 +19,6 @@ import org.junit.jupiter.api.Assertions;
 import org.junit.runner.RunWith;
 import org.mockito.junit.MockitoJUnitRunner;
 import org.opengroup.osdu.notification.provider.azure.util.GoogleServiceAccountImpl;
-import sun.reflect.generics.reflectiveObjects.NotImplementedException;
 
 import static org.junit.Assert.fail;
 
@@ -39,7 +38,7 @@ public class GoogleServiceAccountImpTest {
             // Assert
             fail("Should throw exception");
         } catch (Exception e) {
-            Assertions.assertEquals(e.getClass(), NotImplementedException.class);
+            Assertions.assertEquals(e.getClass(), UnsupportedOperationException.class);
         }
     }
 }
diff --git a/provider/notification-azure/src/test/java/org/opengroup/osdu/notification/util/ServiceAccountClientImplTest.java b/provider/notification-azure/src/test/java/org/opengroup/osdu/notification/util/ServiceAccountClientImplTest.java
index 329b271ab..6516eafa2 100644
--- a/provider/notification-azure/src/test/java/org/opengroup/osdu/notification/util/ServiceAccountClientImplTest.java
+++ b/provider/notification-azure/src/test/java/org/opengroup/osdu/notification/util/ServiceAccountClientImplTest.java
@@ -20,8 +20,6 @@ import org.junit.runner.RunWith;
 import org.mockito.InjectMocks;
 import org.mockito.Mock;
 import org.mockito.junit.MockitoJUnitRunner;
-import org.mockito.junit.jupiter.MockitoExtension;
-import org.omg.CORBA.portable.ApplicationException;
 import org.opengroup.osdu.azure.util.AzureServicePrincipleTokenService;
 import org.opengroup.osdu.core.common.model.http.AppException;
 import org.opengroup.osdu.notification.provider.azure.util.ServiceAccountJwtAzureClientImpl;
@@ -45,7 +43,7 @@ public class ServiceAccountClientImplTest {
     private AzureServicePrincipleTokenService azureServicePrincipleTokenService;
 
     @Test
-    public void shouldSuccessfullyGenerateToken() throws UnsupportedEncodingException, ApplicationException {
+    public void shouldSuccessfullyGenerateToken() throws UnsupportedEncodingException {
 
         when(azureServicePrincipleTokenService.getAuthorizationToken()).thenReturn(token);
 
diff --git a/provider/notification-gc/pom.xml b/provider/notification-gc/pom.xml
index 28cb0a430..151689021 100644
--- a/provider/notification-gc/pom.xml
+++ b/provider/notification-gc/pom.xml
@@ -30,7 +30,7 @@
     </parent>
 
     <properties>
-        <java.version>8</java.version>
+        <java.version>17</java.version>
         <maven.compiler.target>${java.version}</maven.compiler.target>
         <maven.compiler.source>${java.version}</maven.compiler.source>
         <spring-boot-maven-plugin.version>2.7.6</spring-boot-maven-plugin.version>
@@ -156,7 +156,7 @@
             <plugin>
 				<groupId>org.jacoco</groupId>
 				<artifactId>jacoco-maven-plugin</artifactId>
-				<version>0.7.7.201606060606</version>
+				<version>0.8.10</version>
 				<executions>
 					<execution>
 						<goals>
diff --git a/provider/notification-ibm/pom.xml b/provider/notification-ibm/pom.xml
index 27015c550..acc657362 100644
--- a/provider/notification-ibm/pom.xml
+++ b/provider/notification-ibm/pom.xml
@@ -29,7 +29,7 @@
     </parent>
 
     <properties>
-        <java.version>8</java.version>
+        <java.version>17</java.version>
         <maven.compiler.target>${java.version}</maven.compiler.target>
         <maven.compiler.source>${java.version}</maven.compiler.source>
         <undertow-websockets-jsr.version>2.2.11.Final</undertow-websockets-jsr.version>
diff --git a/testing/notification-test-aws/pom.xml b/testing/notification-test-aws/pom.xml
index 761d03a1a..778b41406 100644
--- a/testing/notification-test-aws/pom.xml
+++ b/testing/notification-test-aws/pom.xml
@@ -33,7 +33,7 @@
     <packaging>jar</packaging>
 
     <properties>
-        <java.version>8</java.version>
+        <java.version>17</java.version>
         <maven.compiler.target>${java.version}</maven.compiler.target>
         <maven.compiler.source>${java.version}</maven.compiler.source>
         <jackson-databind.version>2.13.2.2</jackson-databind.version>
diff --git a/testing/notification-test-azure/pom.xml b/testing/notification-test-azure/pom.xml
index 82911504e..01eb31285 100644
--- a/testing/notification-test-azure/pom.xml
+++ b/testing/notification-test-azure/pom.xml
@@ -33,7 +33,7 @@
     <packaging>jar</packaging>
 
     <properties>
-        <java.version>8</java.version>
+        <java.version>17</java.version>
         <maven.compiler.target>${java.version}</maven.compiler.target>
         <maven.compiler.source>${java.version}</maven.compiler.source>
     </properties>
diff --git a/testing/notification-test-baremetal/pom.xml b/testing/notification-test-baremetal/pom.xml
index f00df87b8..f72a39bc2 100644
--- a/testing/notification-test-baremetal/pom.xml
+++ b/testing/notification-test-baremetal/pom.xml
@@ -32,7 +32,7 @@
     <packaging>jar</packaging>
 
     <properties>
-        <java.version>8</java.version>
+        <java.version>17</java.version>
         <maven.compiler.target>${java.version}</maven.compiler.target>
         <maven.compiler.source>${java.version}</maven.compiler.source>
     </properties>
diff --git a/testing/notification-test-core/pom.xml b/testing/notification-test-core/pom.xml
index bb96ff8f3..e82d68532 100644
--- a/testing/notification-test-core/pom.xml
+++ b/testing/notification-test-core/pom.xml
@@ -33,7 +33,7 @@
     <packaging>jar</packaging>
 
     <properties>
-        <java.version>8</java.version>
+        <java.version>17</java.version>
         <maven.compiler.target>${java.version}</maven.compiler.target>
         <maven.compiler.source>${java.version}</maven.compiler.source>
         <jackson-databind.version>2.13.2.2</jackson-databind.version>
diff --git a/testing/notification-test-gc/pom.xml b/testing/notification-test-gc/pom.xml
index 6df54d186..80d99e36e 100644
--- a/testing/notification-test-gc/pom.xml
+++ b/testing/notification-test-gc/pom.xml
@@ -32,7 +32,7 @@
     <packaging>jar</packaging>
 
     <properties>
-        <java.version>8</java.version>
+        <java.version>17</java.version>
         <maven.compiler.target>${java.version}</maven.compiler.target>
         <maven.compiler.source>${java.version}</maven.compiler.source>
     </properties>
@@ -51,7 +51,7 @@
         <dependency>
             <groupId>org.projectlombok</groupId>
             <artifactId>lombok</artifactId>
-            <version>1.18.8</version>
+            <version>1.18.26</version>
         </dependency>
         <dependency>
             <groupId>org.opengroup.osdu</groupId>
diff --git a/testing/notification-test-ibm/pom.xml b/testing/notification-test-ibm/pom.xml
index 8225126e7..71b1fd919 100644
--- a/testing/notification-test-ibm/pom.xml
+++ b/testing/notification-test-ibm/pom.xml
@@ -30,7 +30,7 @@
     <packaging>jar</packaging>
 
     <properties>
-        <java.version>8</java.version>
+        <java.version>17</java.version>
         <maven.compiler.target>${java.version}</maven.compiler.target>
         <maven.compiler.source>${java.version}</maven.compiler.source>
         <os-core-lib-ibm.version>0.23.0</os-core-lib-ibm.version>
-- 
GitLab