Skip to content

Commit

Permalink
EPMRPP-93641 migrate to JDK 21
Browse files Browse the repository at this point in the history
  • Loading branch information
grabsefx committed Oct 21, 2024
1 parent ce13df3 commit 9478ab1
Show file tree
Hide file tree
Showing 241 changed files with 11,551 additions and 13,842 deletions.
72 changes: 39 additions & 33 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
import org.owasp.dependencycheck.reporting.ReportGenerator

plugins {
id 'io.spring.dependency-management' version '1.0.9.RELEASE'
id 'io.spring.dependency-management' version '1.1.6'
id 'java'
id 'java-library'
id 'nu.studer.jooq' version '3.0.3'
id 'org.owasp.dependencycheck' version '5.3.1'
id 'org.owasp.dependencycheck' version '10.0.4'
id "org.jooq.jooq-codegen-gradle" version "${jooqVersion}"
}

apply from: 'project-properties.gradle'
apply from: "$scriptsUrl/release-commons.gradle"
apply from: "$scriptsUrl/signing.gradle"
apply from: "$scriptsUrl/copy-database-scripts.gradle"
apply from: "$scriptsUrl/build-quality.gradle"
apply from: "$scriptsUrl/jacoco.gradle"
//apply from: "$scriptsUrl/build-quality.gradle"
//apply from: "$scriptsUrl/jacoco.gradle" // fix scripts firstly
apply from: 'jooq.gradle'


repositories {
mavenCentral { url "https://repo1.maven.org/maven2" }

Expand All @@ -24,6 +25,8 @@ repositories {
}
}

ext['spring-boot.version'] = "${springBootVersion}"

dependencyManagement {
imports {
mavenBom(releaseMode ? 'com.epam.reportportal:commons-bom:5.11.7' : 'com.epam.reportportal:commons-bom:5.11.7')
Expand All @@ -33,50 +36,50 @@ dependencyManagement {

dependencies {
if (releaseMode) {
compile 'com.epam.reportportal:commons'
implementation 'com.epam.reportportal:commons'
} else {
implementation 'com.github.reportportal:commons:d4be022'
}

// jooq dependencies
implementation "org.jooq:jooq:${jooqVersion}"
implementation "org.postgresql:postgresql:${jdbcDriverVersion}"
jooqCodegen "org.postgresql:postgresql:${jdbcDriverVersion}"

implementation 'jakarta.xml.bind:jakarta.xml.bind-api:4.0.2'
implementation 'com.sun.xml.bind:jaxb-impl:4.0.5'
implementation 'javax.xml.bind:jaxb-api:2.4.0-b180830.0359'
implementation 'javax.servlet:javax.servlet-api:4.0.1' // get rid of unnecessary dep. and resolve conflicts with 'commons'

implementation 'org.springframework.security:spring-security-core'
implementation 'org.springframework:spring-webmvc'
implementation 'org.apache.tika:tika-core'

//https://nvd.nist.gov/vuln/detail/CVE-2020-10683 (dom4j 2.1.3 version dependency) AND https://nvd.nist.gov/vuln/detail/CVE-2019-14900
compile('org.springframework.boot:spring-boot-starter-data-jpa') {
implementation('org.springframework.boot:spring-boot-starter-data-jpa') {
exclude group: 'org.hibernate', module: 'hibernate-core'
}
implementation 'org.springframework:spring-jdbc:5.3.33'
implementation 'org.hibernate:hibernate-core:5.6.15.Final'
//

//https://nvd.nist.gov/vuln/detail/CVE-2020-13692
compile 'org.postgresql:postgresql:42.7.3'
compile 'org.jooq:jooq'
jooqRuntime 'org.postgresql:postgresql:42.7.3'
implementation 'io.minio:minio:8.5.12'

compile 'io.minio:minio:6.0.13'
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310'
implementation 'org.hibernate.validator:hibernate-validator'

implementation group: 'org.json', name: 'json', version: '20231013'
compile 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310'
compile 'org.hibernate.validator:hibernate-validator'

compile 'org.apache.commons:commons-collections4:4.4'
compile 'commons-fileupload:commons-fileupload:1.4'
compile('commons-validator:commons-validator:1.6') {
implementation 'org.apache.commons:commons-collections4:4.4'
implementation 'commons-fileupload:commons-fileupload:1.5' // get rid of unnecessary dep. use spring multipart instead
implementation ('commons-validator:commons-validator:1.9.0') {
exclude group: 'commons-beanutils', module: 'commons-beanutils'
}

compile 'org.jasypt:jasypt:1.9.3'
implementation 'org.jasypt:jasypt:1.9.3'

compile 'io.zonky.test:embedded-postgres:2.0.6'
//Fix CVE-2024-25710, CVE-2024-26308
compile 'org.apache.commons:commons-compress:1.26.0'
compile 'org.flywaydb:flyway-core:6.3.1'
implementation 'io.zonky.test:embedded-postgres:2.0.7'
implementation 'org.apache.commons:commons-compress:1.26.1'
implementation 'org.flywaydb:flyway-core:10.15.2'

compile 'org.apache.jclouds.api:s3:2.5.0'
compile 'org.apache.jclouds.provider:aws-s3:2.5.0'
implementation 'org.apache.jclouds.api:filesystem:2.5.0'
implementation "org.apache.jclouds.api:s3:${jcloudsVersion}"
implementation "org.apache.jclouds.provider:aws-s3:${jcloudsVersion}"
implementation "org.apache.jclouds.api:filesystem:${jcloudsVersion}"
implementation 'com.google.guava:guava:33.2.1-jre'

// add lombok support
compileOnly "org.projectlombok:lombok:${lombokVersion}"
Expand All @@ -87,7 +90,9 @@ dependencies {
implementation 'com.github.ben-manes.caffeine:caffeine'

testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.flywaydb.flyway-test-extensions:flyway-spring-test:6.1.0'
implementation 'org.flywaydb:flyway-database-postgresql:10.20.0'

testImplementation 'org.flywaydb.flyway-test-extensions:flyway-spring6-test:10.0.0'

}

Expand All @@ -110,6 +115,7 @@ tasks.withType(JavaCompile) {
options.debugOptions.debugLevel = "source,lines,vars"
}


checkCommitNeeded.dependsOn removeScripts
test.dependsOn copyTestDatabaseScripts
build.dependsOn jacocoTestReport
//build.dependsOn jacocoTestReport
6 changes: 5 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
version=5.11.7
lombokVersion=1.18.30
springBootVersion=3.3.4
lombokVersion=1.18.34
jooqVersion=3.19.13
jdbcDriverVersion=42.7.3
jcloudsVersion=2.6.0
5 changes: 2 additions & 3 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#Fri Mar 13 21:13:13 MSK 2020
distributionUrl=https\://services.gradle.org/distributions/gradle-6.0-all.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 1 addition & 1 deletion jitpack.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
jdk:
- openjdk11
- openjdk21
14 changes: 2 additions & 12 deletions jooq.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
jooq {
version = '3.12.4'
edition = 'OSS'
sample(sourceSets.main) {
configuration {
jdbc {
driver = 'org.postgresql.Driver'
url = 'jdbc:postgresql://localhost:5432/reportportal'
Expand All @@ -11,22 +9,18 @@ jooq {
generator {
strategy {
name = 'org.jooq.codegen.example.JPrefixGeneratorStrategy'
// ...
}
database {
name = 'org.jooq.meta.postgres.PostgresDatabase'
inputSchema = (hasDBSchema ? getProperty('DB_SCHEMA_POSTGRES') : 'public')
// ...

excludes = 'batch_.*|schema_migrations'
forcedTypes {
forcedType {

// Specify the Java type of your custom type. This corresponds to the Converter's <U> type.
userType = "java.time.Instant"

// Associate that custom type with your converter.
converter = "com.epam.ta.reportportal.dao.converters.JooqInstantConverter"

// A Java regex matching fully-qualified columns, attributes, parameters. Use the pipe to separate several expressions.
types = "TIMESTAMP"
}
Expand All @@ -46,7 +40,3 @@ jooq {
}
}
}

generateSampleJooqSchemaSource {
enabled = false
}
8 changes: 2 additions & 6 deletions project-properties.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21

def commonScriptsUrl = 'https://raw.githubusercontent.com/reportportal/gradle-scripts/'
def migrationsScriptsUrl = 'https://raw.githubusercontent.com/reportportal/migrations/'
Expand Down Expand Up @@ -111,7 +111,3 @@ project.ext {
'class' : 87
]
}

wrapper {
gradleVersion = '6.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.commons.CommonsMultipartFile;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
Expand Down Expand Up @@ -128,9 +127,9 @@ public Optional<BinaryDataMetaInfo> saveAttachment(AttachmentMetaInfo metaInfo,
} catch (IOException e) {
LOGGER.error("Unable to save binary data", e);
} finally {
if (file instanceof CommonsMultipartFile) {
/* if (file instanceof CommonsMultipartFile) {
((CommonsMultipartFile) file).getFileItem().delete();
}
}*/
}
return result;
}
Expand Down

This file was deleted.

35 changes: 16 additions & 19 deletions src/main/java/com/epam/ta/reportportal/commons/JsonbUserType.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,36 +41,33 @@
/**
* @author <a href="mailto:[email protected]">Pavel Bortnik</a>
*/
public abstract class JsonbUserType implements UserType {
public abstract class JsonbUserType<T> implements UserType<T> {

private final ObjectMapper mapper;

public JsonbUserType() {
protected JsonbUserType() {
mapper = new ObjectMapper();
mapper.registerModule(new JavaTimeModule());
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
}

@Override
public int[] sqlTypes() {
return new int[]{Types.JAVA_OBJECT};
public int getSqlType() {
return Types.JAVA_OBJECT;
}

@Override
abstract public Class<?> returnedClass();

@Override
public Object nullSafeGet(ResultSet rs, String[] names, SharedSessionContractImplementor session,
Object owner)
throws HibernateException, SQLException {
if (rs.getObject(names[0]) == null) {
public T nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session,
Object owner) throws SQLException {
if (rs.getObject(position) == null) {
return null;
}
PGobject pgObject = (PGobject) rs.getObject(names[0]);
PGobject pgObject = (PGobject) rs.getObject(position);
try {
return mapper.readValue(pgObject.getValue(), this.returnedClass());
} catch (Exception e) {
throw new ReportPortalException("Failed to convert String to Invoice: " + e.getMessage(), e);
throw new ReportPortalException(
String.format("Failed to convert String to '%s' ", this.returnedClass().getName()), e);
}
}

Expand All @@ -95,7 +92,7 @@ public void nullSafeSet(PreparedStatement st, Object value, int index,
}

@Override
public Object deepCopy(Object value) throws HibernateException {
public T deepCopy(Object value) throws HibernateException {
try (ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(
bos)) {
// use serialization to create a deep copy
Expand All @@ -104,7 +101,7 @@ public Object deepCopy(Object value) throws HibernateException {
oos.flush();

ByteArrayInputStream bais = new ByteArrayInputStream(bos.toByteArray());
return new ObjectInputStream(bais).readObject();
return (T) new ObjectInputStream(bais).readObject();
} catch (ClassNotFoundException | IOException ex) {
throw new HibernateException(ex);
}
Expand All @@ -113,21 +110,21 @@ public Object deepCopy(Object value) throws HibernateException {
@Override
public Serializable disassemble(Object value) throws HibernateException {
Object copy = deepCopy(value);
if (copy instanceof Serializable) {
return (Serializable) copy;
if (copy instanceof Serializable serializable) {
return serializable;
}
throw new SerializationException(
String.format("Cannot serialize '%s', %s is not Serializable.", value, value.getClass()),
null);
}

@Override
public Object assemble(Serializable cached, Object owner) throws HibernateException {
public T assemble(Serializable cached, Object owner) throws HibernateException {
return deepCopy(cached);
}

@Override
public Object replace(Object original, Object target, Object owner) throws HibernateException {
public T replace(Object original, Object target, Object owner) throws HibernateException {
return deepCopy(original);
}

Expand Down
Loading

0 comments on commit 9478ab1

Please sign in to comment.