Skip to content

Commit

Permalink
Merge pull request #759 from amvanbaren/feature/issue-745
Browse files Browse the repository at this point in the history
Upgrade to Java 17
  • Loading branch information
amvanbaren authored Jun 20, 2023
2 parents 63eae3e + 6044b88 commit cbf247e
Show file tree
Hide file tree
Showing 121 changed files with 674 additions and 567 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: 11
java-version: 17
- name: Install Yarn
run: npm install --global yarn
- uses: actions/checkout@v2
Expand Down
8 changes: 3 additions & 5 deletions .gitpod.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ ENV DOCKER_BUMP=2
USER gitpod

RUN bash -c ". /home/gitpod/.sdkman/bin/sdkman-init.sh \
# Install Java 18 for the Java extension to function properly
&& sdk install java 18.0.1.1-open \
&& sdk install java 11.0.2-open"
&& sdk install java 17.0.7-tem"

RUN curl https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.11.0-linux-x86_64.tar.gz --output elasticsearch-linux-x86_64.tar.gz \
RUN curl https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.7.1-linux-x86_64.tar.gz --output elasticsearch-linux-x86_64.tar.gz \
&& tar -xzf elasticsearch-linux-x86_64.tar.gz \
&& rm elasticsearch-linux-x86_64.tar.gz
ENV ES_HOME="$HOME/elasticsearch-7.11.0"
ENV ES_HOME="$HOME/elasticsearch-8.7.1"
2 changes: 1 addition & 1 deletion .gitpod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ tasks:
command: |
if [[ $NPM_TOKEN ]]; then echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc; fi
# Start Elasticsearch as background process
$ES_HOME/bin/elasticsearch -d -p $ES_HOME/pid -Ediscovery.type=single-node -Expack.ml.enabled=false
$ES_HOME/bin/elasticsearch -d -p $ES_HOME/pid -Ediscovery.type=single-node -Expack.ml.enabled=false -Expack.security.enabled=false
gp ports await 9200
# Start the server application
cd server
Expand Down
18 changes: 11 additions & 7 deletions doc/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,13 @@ To get started quickly, it is recommended to use Gitpod as default with the deve

- [https://docs.microsoft.com/en-us/windows/dev-environment/javascript/nodejs-on-wsl](https://docs.microsoft.com/en-us/windows/dev-environment/javascript/nodejs-on-wsl)

- Set up JDK 11

- sudo apt install onpenjdk-11-jdk
- Set up JDK 17
- sudo apt install -y wget apt-transport-https
- mkdir -p /etc/apt/keyrings
- wget -O - https://packages.adoptium.net/artifactory/api/gpg/key/public | tee /etc/apt/keyrings/adoptium.asc
- echo "deb [signed-by=/etc/apt/keyrings/adoptium.asc] https://packages.adoptium.net/artifactory/deb $(awk -F= '/^VERSION_CODENAME/{print$2}' /etc/os-release) main" | tee /etc/apt/sources.list.d/adoptium.list
- sudo apt update
- sudo apt install temurin-17-jdk

- Install docker

Expand Down Expand Up @@ -74,15 +78,15 @@ To get started quickly, it is recommended to use Gitpod as default with the deve

- Make sure the correct Java version is being used

- Download Java 11 if you don't have it already
- Download Java 17 if you don't have it already: https://adoptium.net/temurin/releases/

- Run the command `/usr/libexec/java_home –V` to see your matching Java virtual machines

- Pick Java 11 accordingly
- Pick Java 17 accordingly

- export JAVA_HOME='/usr/libexec/java_home –v 11.0.18'
- export JAVA_HOME='/usr/libexec/java_home –v 17.0.7+7'

- Run `java –version` to check if Java 11 is indeed being used
- Run `java –version` to check if Java 17 is indeed being used

- https://stackoverflow.com/questions/21964709/how-to-set-or-change-the-default-java-jdk-version-on-macos

Expand Down
4 changes: 2 additions & 2 deletions server/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM gradle:jdk11 as builder
FROM gradle:jdk17 as builder

# Copy sources
WORKDIR /home/gradle
Expand All @@ -10,7 +10,7 @@ COPY --chown=gradle:gradle src ./src/
RUN ./gradlew --no-daemon assemble


FROM openjdk:11.0.7-jdk
FROM eclipse-temurin:17.0.7_7-jdk

# Create user openvsx and set up home directory
RUN groupadd -r openvsx && useradd --no-log-init -r -g openvsx openvsx
Expand Down
49 changes: 25 additions & 24 deletions server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ buildscript {
mavenCentral()
}
dependencies {
classpath "org.hibernate:hibernate-gradle-plugin:5.4.22.Final"
classpath "org.hibernate.orm:hibernate-gradle-plugin:6.2.2.Final"
}
}
plugins {
id 'nu.studer.jooq' version '6.0.1'
id 'de.undercouch.download' version '4.1.1'
id 'org.springframework.boot' version '2.7.1'
id 'org.springframework.boot' version '3.1.0'
id 'io.spring.dependency-management' version '1.1.0'
id 'io.gatling.gradle' version '3.6.1'
id 'java'
Expand All @@ -18,22 +18,26 @@ apply plugin: 'org.hibernate.orm'

def jooqSrcDir = 'src/main/jooq-gen'
def versions = [
java: '11',
flyway: '7.3.1',
springdoc: '1.6.9',
spdx: '2.2.4',
gcloud: '1.113.4',
azure: '12.9.0',
guava: '28.2-jre',
java: '17',
flyway: '9.19.1',
springdoc: '2.1.0',
spdx: '2.2.8',
gcloud: '2.22.3',
azure: '12.18.0',
guava: '30.0-jre',
junit: '5.7.1',
testcontainers: '1.15.2',
jackson: '2.12.5',
woodstox: '6.2.4',
jobrunr: '5.1.2',
bucket4j: '0.4.0',
ehcache: '3.10.0',
jackson: '2.15.2',
woodstox: '6.4.0',
jobrunr: '6.2.0',
bucket4j: '0.9.0',
ehcache: '3.10.8',
tika: '2.6.0',
bouncycastle: '1.69'
bouncycastle: '1.69',
commons_lang3: '3.12.0',
httpclient5: '5.2.1',
jaxb_api: '2.3.1',
jaxb_impl: '2.3.8'
]
ext['junit-jupiter.version'] = versions.junit
sourceCompatibility = versions.java
Expand Down Expand Up @@ -75,18 +79,22 @@ dependencies {
implementation "org.bouncycastle:bcpkix-jdk15on:${versions.bouncycastle}"
implementation "org.ehcache:ehcache:${versions.ehcache}"
implementation "com.giffing.bucket4j.spring.boot.starter:bucket4j-spring-boot-starter:${versions.bucket4j}"
implementation "org.jobrunr:jobrunr-spring-boot-starter:${versions.jobrunr}"
implementation "org.jobrunr:jobrunr-spring-boot-3-starter:${versions.jobrunr}"
implementation "org.flywaydb:flyway-core:${versions.flyway}"
implementation "com.google.cloud:google-cloud-storage:${versions.gcloud}"
implementation "com.azure:azure-storage-blob:${versions.azure}"
implementation "org.springdoc:springdoc-openapi-ui:${versions.springdoc}"
implementation "org.springdoc:springdoc-openapi-starter-webmvc-ui:${versions.springdoc}"
implementation "com.google.guava:guava:${versions.guava}"
implementation "com.fasterxml.jackson.core:jackson-core:${versions.jackson}"
implementation "com.fasterxml.jackson.core:jackson-annotations:${versions.jackson}"
implementation "com.fasterxml.jackson.core:jackson-databind:${versions.jackson}"
implementation "com.fasterxml.jackson.module:jackson-module-jaxb-annotations:${versions.jackson}"
implementation "com.fasterxml.woodstox:woodstox-core:${versions.woodstox}"
implementation "com.fasterxml.jackson.dataformat:jackson-dataformat-xml:${versions.jackson}"
implementation "javax.xml.bind:jaxb-api:${versions.jaxb_api}"
implementation "com.sun.xml.bind:jaxb-impl:${versions.jaxb_impl}"
implementation "org.apache.commons:commons-lang3:${versions.commons_lang3}"
implementation "org.apache.httpcomponents.client5:httpclient5:${versions.httpclient5}"
implementation "org.apache.tika:tika-core:${versions.tika}"
implementation("org.spdx:spdx-tools:${versions.spdx}") {
exclude group: 'net.sf.saxon'
Expand All @@ -109,13 +117,6 @@ dependencies {
testRuntimeOnly "org.testcontainers:postgresql:${versions.testcontainers}"
}

hibernate {
enhance {
enableLazyInitialization = true
enableDirtyTracking = true
}
}

jooq {
// use jOOQ version defined in Spring Boot
version = dependencyManagement.importedProperties['jooq.version']
Expand Down
2 changes: 1 addition & 1 deletion server/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
10 changes: 5 additions & 5 deletions server/gradlew
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh

#
# Copyright © 2015-2021 the original authors.
# Copyright 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -32,10 +32,10 @@
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
# * expansions $var�, �${var}�, �${var:-default}�, �${var+SET},
# ${var#prefix}�, �${var%suffix}, and $( cmd );
# * compound commands having a testable exit status, especially case;
# * various built-in commands including command�, �set, and ulimit.
#
# Important for patching:
#
Expand Down
7 changes: 4 additions & 3 deletions server/src/dev/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ management:

springdoc:
swagger-ui:
path: /swagger-ui
docExpansion: list
operationsSorter: alpha
supportedSubmitMethods:
Expand Down Expand Up @@ -93,7 +94,7 @@ bucket4j:
Access-Control-Allow-Origin: '*'
Access-Control-Expose-Headers: X-Rate-Limit-Retry-After-Seconds, X-Rate-Limit-Remaining
rate-limits:
- expression: getParameter("token")
- cache-key: getParameter("token")
bandwidths:
- capacity: 15
time: 1
Expand All @@ -104,7 +105,7 @@ bucket4j:
Access-Control-Allow-Origin: '*'
Access-Control-Expose-Headers: X-Rate-Limit-Retry-After-Seconds, X-Rate-Limit-Remaining
rate-limits:
- expression: getRemoteAddr()
- cache-key: getRemoteAddr()
bandwidths:
- capacity: 75
time: 1
Expand All @@ -115,7 +116,7 @@ bucket4j:
Access-Control-Allow-Origin: '*'
Access-Control-Expose-Headers: X-Rate-Limit-Retry-After-Seconds, X-Rate-Limit-Remaining
rate-limits:
- expression: getRemoteAddr()
- cache-key: getRemoteAddr()
bandwidths:
- capacity: 15
time: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
import com.fasterxml.jackson.databind.node.MissingNode;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.openvsx.entities.ExtensionVersion;
import org.eclipse.openvsx.entities.FileResource;
import org.eclipse.openvsx.util.*;
import org.elasticsearch.common.Strings;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.util.Pair;
Expand Down Expand Up @@ -273,7 +273,7 @@ private List<String> getTags() {
}

private List<String> asStringList(String value, String sep){
if (Strings.isNullOrEmpty(value)){
if (StringUtils.isEmpty(value)){
return new ArrayList<>();
}

Expand Down Expand Up @@ -410,7 +410,7 @@ public FileResource getLicense(ExtensionVersion extVersion) {
license.setExtension(extVersion);
license.setType(FileResource.LICENSE);
// Parse specifications in the form "SEE MIT LICENSE IN LICENSE.txt"
if (!Strings.isNullOrEmpty(extVersion.getLicense())) {
if (!StringUtils.isEmpty(extVersion.getLicense())) {
var matcher = LICENSE_PATTERN.matcher(extVersion.getLicense());
if (matcher.find()) {
extVersion.setLicense(matcher.group("license"));
Expand Down Expand Up @@ -438,7 +438,7 @@ public FileResource getLicense(ExtensionVersion extVersion) {
}

private void detectLicense(byte[] content, ExtensionVersion extVersion) {
if (Strings.isNullOrEmpty(extVersion.getLicense())) {
if (StringUtils.isEmpty(extVersion.getLicense())) {
var detection = new LicenseDetection();
extVersion.setLicense(detection.detectLicense(content));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@
import java.time.LocalDateTime;
import java.util.LinkedHashSet;

import javax.transaction.Transactional;
import javax.transaction.Transactional.TxType;

import com.google.common.base.Strings;
import jakarta.transaction.Transactional;
import jakarta.transaction.Transactional.TxType;

import org.apache.commons.lang3.StringUtils;
import org.eclipse.openvsx.cache.CacheService;
import org.eclipse.openvsx.entities.*;
import org.eclipse.openvsx.publish.PublishExtensionVersionHandler;
Expand Down Expand Up @@ -102,7 +101,7 @@ private TempFile createExtensionFile(InputStream content) {
}

private void checkLicense(ExtensionVersion extVersion, FileResource license) {
if (Strings.isNullOrEmpty(extVersion.getLicense()) && (license == null || !license.getType().equals(FileResource.LICENSE))) {
if (StringUtils.isEmpty(extVersion.getLicense()) && (license == null || !license.getType().equals(FileResource.LICENSE))) {
throw new ErrorResultException("This extension cannot be accepted because it has no license.");
}
}
Expand Down
16 changes: 8 additions & 8 deletions server/src/main/java/org/eclipse/openvsx/ExtensionValidator.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
********************************************************************************/
package org.eclipse.openvsx;

import com.google.common.base.Strings;
import org.apache.commons.lang3.StringUtils;
import org.apache.tika.Tika;
import org.apache.tika.mime.MediaType;
import org.apache.tika.mime.MimeTypeException;
Expand Down Expand Up @@ -48,7 +48,7 @@ public class ExtensionValidator {
private final Pattern namePattern = Pattern.compile("[\\w\\-\\+\\$~]+");

public Optional<Issue> validateNamespace(String namespace) {
if (Strings.isNullOrEmpty(namespace) || namespace.equals("-")) {
if (StringUtils.isEmpty(namespace) || namespace.equals("-")) {
return Optional.of(new Issue("Namespace name must not be empty."));
}
if (!namePattern.matcher(namespace).matches()) {
Expand Down Expand Up @@ -102,7 +102,7 @@ public List<Issue> validateNamespaceDetails(NamespaceDetailsJson json) {
}

public Optional<Issue> validateExtensionName(String name) {
if (Strings.isNullOrEmpty(name)) {
if (StringUtils.isEmpty(name)) {
return Optional.of(new Issue("Name must not be empty."));
}
if (!namePattern.matcher(name).matches()) {
Expand Down Expand Up @@ -156,7 +156,7 @@ public List<Issue> validateMetadata(ExtensionVersion extVersion) {
}

private void checkVersion(String version, List<Issue> issues) {
if (Strings.isNullOrEmpty(version)) {
if (StringUtils.isEmpty(version)) {
issues.add(new Issue("Version must not be empty."));
return;
}
Expand Down Expand Up @@ -216,7 +216,7 @@ private void checkFieldSize(List<String> values, int limit, String field, List<I
}

private void checkInvalid(String value, Predicate<String> isInvalid, String field, List<Issue> issues, String allowedValues) {
if (Strings.isNullOrEmpty(value)) {
if (StringUtils.isEmpty(value)) {
return;
}
if (isInvalid.test(value)) {
Expand All @@ -226,7 +226,7 @@ private void checkInvalid(String value, Predicate<String> isInvalid, String fiel
}

private void checkURL(String value, String field, List<Issue> issues) {
if (Strings.isNullOrEmpty(value)) {
if (StringUtils.isEmpty(value)) {
return;
}
if (isInvalidURL(value)) {
Expand All @@ -235,14 +235,14 @@ private void checkURL(String value, String field, List<Issue> issues) {
}

private boolean isInvalidURL(String value) {
if (Strings.isNullOrEmpty(value))
if (StringUtils.isEmpty(value))
return true;
if (value.startsWith("git+") && value.length() > 4)
value = value.substring(4);

try {
var url = new URL(value);
return url.getProtocol().matches("http(s)?") && Strings.isNullOrEmpty(url.getHost());
return url.getProtocol().matches("http(s)?") && StringUtils.isEmpty(url.getHost());
} catch (MalformedURLException exc) {
return true;
}
Expand Down
Loading

0 comments on commit cbf247e

Please sign in to comment.