Skip to content

Commit

Permalink
Merge pull request #1432 from CMSgov/feature/java_upgrade
Browse files Browse the repository at this point in the history
QPPSE-1933: Java 11 to 17 migration
  • Loading branch information
sivaksb authored Apr 23, 2024
2 parents 969c1b5 + 69ea223 commit a6aa487
Show file tree
Hide file tree
Showing 26 changed files with 94 additions and 172 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ jobs:
uses: zricethezav/gitleaks-action@6e41781c235feb424ecc3435610dce20ad349a70 # pin@master


- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: "11"
java-version: "17"
distribution: "corretto"

- name: Delete old dependencies (may trigger Snyk vulnerability otherwise)
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/draft-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
uses: salsify/action-detect-and-tag-new-version@68bbe8670f415d304e02942186441939c4692aa6 # [email protected]
with:
version-command: |
mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version | grep -v '\['
mvn org.apache.maven.plugins:maven-help-plugin:3.4.0:evaluate -Dexpression=project.version | grep -v '\['
- name: Draft release notes
uses: release-drafter/release-drafter@06d4616a80cd7c09ea3cf12214165ad6c1859e67 #v5.11
Expand Down
2 changes: 1 addition & 1 deletion .java-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
11
17
2 changes: 1 addition & 1 deletion DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ if you'd like to contribute to qpp-conversion-tool.

The additional prerequisites that were not already outlined in the
[main README][readme] are...
- [Java Development Kit](http://www.oracle.com/technetwork/java/javase/downloads/index.html) (version `>= 1.8`). The Java Runtime
- [Java Development Kit](http://www.oracle.com/technetwork/java/javase/downloads/index.html) (version `>= 17`). The Java Runtime
will not suffice.
- [Maven](https://maven.apache.org).

Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
FROM eclipse-temurin:11
FROM eclipse-temurin:17

ARG MAVEN_VERSION=3.8.4
ARG MAVEN_VERSION=3.9.6
ARG USER_HOME_DIR="/root"
ARG SHA=a9b2d825eacf2e771ed5d6b0e01398589ac1bfa4171f36154d1b5787879605507802f699da6f7cfc80732a5282fd31b28e4cd6052338cbef0fa1358b48a5e3c8
ARG SHA=706f01b20dec0305a822ab614d51f32b07ee11d0218175e55450242e49d2156386483b506b3a4e8a03ac8611bae96395fd5eec15f50d3013d5deed6d1ee18224
ARG BASE_URL=https://archive.apache.org/dist/maven/maven-3/${MAVEN_VERSION}/binaries/

RUN mkdir -p /usr/share/maven /usr/share/maven/ref \
Expand Down
2 changes: 1 addition & 1 deletion DockerfileTest
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM maven:3.6.3-jdk-11
FROM maven:3.9.6-eclipse-temurin-17

RUN mkdir -p /usr/src/app/
RUN mkdir -p /usr/src/run/
Expand Down
21 changes: 0 additions & 21 deletions Jenkinsfile

This file was deleted.

18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,30 @@ Before you can use the qpp-conversion-tool application, you must install and con

[GitHub's Guide to Installing Git](https://help.github.com/articles/set-up-git) is a good source of information.

* [Java Runtime](https://java.com/download) (version `>= 11`).
* [Java Runtime](https://java.com/download) (version `>= 17`).

It is important that you have the right version of `java` on your path.

```shell
# When you run 'java -version', you should get 11. For example:
# When you run 'java -version', you should get 17. For example:
java -version
java version "11"
java version "17"
...
```

Sometimes the Java Runtime installer doesn't update your path. So you must do it manually. Alternatively, download and install
the [Java Development Kit](http://www.oracle.com/technetwork/java/javase/downloads/index.html) (version `>= 11`). The JDK is
the [Java Development Kit](http://www.oracle.com/technetwork/java/javase/downloads/index.html) (version `>= 17`). The JDK is
better at updating your path.

* [Maven](https://maven.apache.org) (version `>= 3.8.4`).
* [Maven](https://maven.apache.org) (version `>= 3.9.6`).

Maven is used to build the application, manage dependencies, and run tests. After you unzip the Maven archive, you need to add
the `bin` directory to your path, as described the [Maven installation instructions](https://maven.apache.org/install.html).

```shell
# When you run 'mvn -v', you should get 3.8.4. For example:
mvn -v
Apache Maven 3.8.4
Apache Maven 3.9.6
...
```
* [Docker](https://www.docker.com).
Expand All @@ -60,6 +60,10 @@ cd ./qpp-conversion-tool

## Running the Converter

### Disable HTTPS

In order to run converter locally, HTTPS may need to be disabled. It can be done by removing or commenting server.port and server.ssl.key-store-type in application.properties file under `rest-api/src/main/resources`

### ReST API via Docker

The Conversion Tool can be executed through a ReST API. Using the ReST API has the added benefit of having the
Expand All @@ -70,7 +74,7 @@ directory.

```shell
# Build the Docker image and run the container using docker-compose.
docker-compose -f ./docker-compose.test.yaml --build up
docker-compose -f ./docker-compose.test.yaml up --build
```

#### Invoking the Endpoint
Expand Down
8 changes: 4 additions & 4 deletions acceptance-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<name>conversion-tests</name>
<packaging>jar</packaging>
<properties>
<java.version>1.8</java.version>
<java.version>17</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<cucumber.version>4.2.5</cucumber.version>
</properties>
Expand All @@ -23,7 +23,7 @@
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>4.2.5</version>
<version>${cucumber.version}</version>
<scope>test</scope>
</dependency>

Expand Down Expand Up @@ -66,8 +66,8 @@
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import gov.cms.qpp.conversion.model.error.LocalizedProblem;
import gov.cms.qpp.test.helper.JsonTestHelper;

@RunWith(PowerMockRunner.class)
@PowerMockIgnore({"org.apache.xerces.*", "javax.xml.parsers.*", "org.xml.sax.*", "com.sun.org.apache.xerces.*" })
public class ConversionFileWriterWrapperTest {

Expand Down
3 changes: 1 addition & 2 deletions commons/src/main/resources/measures-data.json
Original file line number Diff line number Diff line change
Expand Up @@ -48115,8 +48115,7 @@
"6775913",
"6704504",
"9181695",
"7746687",
""
"7746687"
],
"allowedPrograms": [
"mips",
Expand Down
5 changes: 0 additions & 5 deletions converter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,6 @@
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>uk.com.robust-it</groupId>
<artifactId>cloning</artifactId>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.Serializable;
import java.nio.charset.StandardCharsets;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
Expand All @@ -35,7 +36,7 @@
* This class is a wrapper around a container, value, and
* metadata Kind with container types, list and map.
*/
public class JsonWrapper {
public class JsonWrapper implements Serializable {

public static enum Kind {
CONTAINER, VALUE, METADATA;
Expand Down Expand Up @@ -802,8 +803,7 @@ protected boolean validBoolean(String value) {
/**
* Helps enforce the initialized representation of the {@link JsonWrapper} as a hash or an array.
*
* @param check should be null
*/
*/
protected void checkMapState() {
if (isType(Type.MAP)) {
throw new IllegalStateException("Current state may not change (from map to list).");
Expand All @@ -813,8 +813,7 @@ protected void checkMapState() {
/**
* Helps enforce the initialized representation of the {@link JsonWrapper} as a hash or an array.
*
* @param check should be null
*/
*/
protected void checkListState() {
if (isType(Type.LIST)) {
throw new IllegalStateException("Current state may not change (from list to map).");
Expand All @@ -824,7 +823,7 @@ protected void checkListState() {
/**
* Helps enforce no null or empty values added to a {@link JsonWrapper}.
*
* @param check should be null
* @param wrapper should be null
*/
protected boolean checkState(JsonWrapper wrapper) {
if (wrapper == null) { // no null entries
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package gov.cms.qpp.conversion.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
Expand All @@ -26,7 +27,7 @@
* Map that holds the data gleaned from an input file.
* Nodes can contain other nodes as children to create a hierarchy.
*/
public class Node {
public class Node implements Serializable {

public static final int DEFAULT_LOCATION_NUMBER = -1;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
package gov.cms.qpp.conversion.util;

import gov.cms.qpp.conversion.Converter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.rits.cloning.Cloner;
import java.io.*;

/**
* Utility that help clone target objects
*/
public class CloneHelper {
private static final Cloner CACHED = Cloner.standard();

private static final Logger DEV_LOG = LoggerFactory.getLogger(Converter.class);

private CloneHelper(){}

Expand All @@ -19,6 +23,25 @@ private CloneHelper(){}
* @return clone
*/
public static <T> T deepClone(final T in) {
return CACHED.deepClone(in);
T copy;
try {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
ObjectOutputStream output = new ObjectOutputStream(outputStream);
output.writeObject(in);
output.close();

ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
ObjectInputStream input = new ObjectInputStream(inputStream);
copy = (T) input.readObject();
input.close();

} catch(IOException ex) {
DEV_LOG.error("Error cloning object - " + ex.getMessage(), ex);
throw new UncheckedIOException(ex);
} catch(ClassNotFoundException ex) {
DEV_LOG.error("Error cloning object - " + ex.getMessage(), ex);
throw new RuntimeException(ex);
}
return copy;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1131,34 +1131,6 @@ void metadataList_throwsIOE() throws Exception {

assertThrows(RuntimeException.class, () -> {Type.LIST.metadata(value, gen);});
}

@Test
void test_JsonWrapperMetadataSerilizer_jsonContainer_noMetadata() throws Exception {
JsonGenerator gen = mock(JsonGenerator.class);
JsonWrapper.Type map = mock(JsonWrapper.Type.class);
JsonWrapper value = new JsonWrapper().put("value").setType(map);

JsonWrapper.JsonWrapperMetadataSerilizer metaSer = new JsonWrapper.JsonWrapperMetadataSerilizer();
metaSer.jsonContainer(value, gen, null);

// should call the super class handling if metadata is absent from the wrapper
verify(map, times(0)).metadata(value, gen);
verify(map, times(1)).json(value, gen);
}
@Test
void test_JsonWrapperMetadataSerilizer_jsonContainer_withMetadata() throws Exception {
JsonGenerator gen = mock(JsonGenerator.class);
JsonWrapper.Type map = mock(JsonWrapper.Type.class);
JsonWrapper value = new JsonWrapper().put("value").putMetadata("meta", "data");
value.setType(map);

JsonWrapper.JsonWrapperMetadataSerilizer metaSer = new JsonWrapper.JsonWrapperMetadataSerilizer();
metaSer.jsonContainer(value, gen, null);

// should call the metadata method on the type instance if metadata is added to the wrapper
verify(map, times(1)).metadata(value, gen);
verify(map, times(0)).json(value, gen);
}

@Test
void Constructor_throwsUnsupported() throws Exception {
Expand Down
2 changes: 1 addition & 1 deletion generate/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.6.0</version>
<version>3.6.1</version>
<configuration>
<skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
</configuration>
Expand Down
2 changes: 1 addition & 1 deletion isg-okr.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
################################ OKR Metrics Properties for Conversion Tool Releases ############################

# Conversion-Tool Release-version
export rel_version="14.6.0"
export rel_version="2023.5.0-RELEASE"

# Conversion-Tool Release page(id) in Confluence
export confluenceReleasePageId="509718895"
Expand Down
Loading

0 comments on commit a6aa487

Please sign in to comment.