Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
44 changes: 44 additions & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# This workflow builds and pushes the Docker image for the OJP server.
name: OJP Server Docker Image Build

on:
workflow_dispatch:
inputs:
tag:
description: 'Docker image tag'
required: true
default: 'latest'
repository:
description: 'Repository name'
required: true
default: 'rrobetti'
jobs:
build-docker-image:
name: Build Docker Image
runs-on: ubuntu-latest

steps:
- name: Git checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up JDK 22
uses: actions/setup-java@v4
with:
java-version: 22
distribution: 'temurin'
cache: maven

- name: Build and push Docker image
env:
DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
DOCKERHUB_REPO: ${{ github.event.inputs.repository }}
run: |
mvn compile jib:build -pl ojp-server \
-Djib.to.auth.username="${DOCKERHUB_USER}" \
-Djib.to.auth.password="${DOCKERHUB_TOKEN}" \
-Djib.to.image="${DOCKERHUB_REPO}/ojp:${{ github.event.inputs.tag }}" \
-Djib.container.mainClass="org.openjdbcproxy.grpc.server.GrpcServer" \
-Djib.container.ports=1059
44 changes: 44 additions & 0 deletions .github/workflows/main-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# This workflow builds and pushes the Docker image for the OJP server.
# It should only trigger when there are changes in the `ojp-server` or `ojp-grpc-commons` modules.
name: Main OJP Server Docker Image CI

on:
push:
branches: [ main ]
paths:
- '.github/workflows/main-docker.yml'
- 'ojp-server/**'
- 'ojp-grpc-commons/**'

jobs:
build-docker-image:
name: Build Docker Image
runs-on: ubuntu-latest
if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]')"

steps:
- name: Git checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up JDK 22
uses: actions/setup-java@v4
with:
java-version: 22
distribution: 'temurin'
cache: maven

- name: Build and push Docker image
env:
DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
DOCKERHUB_REPO: ${{ vars.DOCKERHUB_REPO }}
run: |
mvn compile jib:build -pl ojp-server \
-Dimage="${DOCKERHUB_REPO}:latest" \
-Djib.to.auth.username="${DOCKERHUB_USER}" \
-Djib.to.auth.password="${DOCKERHUB_TOKEN}" \
-Djib.to.image="${DOCKERHUB_REPO}/ojp:latest" \
-Djib.container.mainClass="org.openjdbcproxy.grpc.server.GrpcServer" \
-Djib.container.ports=1059
30 changes: 25 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ jobs:
name: Build & Test
runs-on: ubuntu-latest
if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]')"
strategy:
fail-fast: false
matrix:
java-version: [ 11, 17, 21, 22 ]

services:
postgres:
Expand All @@ -36,18 +40,34 @@ jobs:
with:
fetch-depth: 0

- name: Set up JDK 22
- name: Set up JDK 22 for ojp-server
uses: actions/setup-java@v4
with:
java-version: 22
distribution: 'temurin'
cache: maven

- name: Build
- name: Build (ojp-server)
run: mvn clean install -DskipTests

- name: Run ojp-server
- name: Test (ojp-server)
run: mvn test -pl ojp-server

- name: Run (ojp-server)
run: mvn verify -pl ojp-server -Prun-ojp-server > ojp-server.log 2>&1 &

- name: Run tests
run: mvn test
- name: Wait for ojp-server to start
run: sleep 10

- name: Set up JDK ${{ matrix.java-version }} for ojp-grpc-commons and ojp-jdbc-driver
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java-version }}
distribution: 'temurin'
cache: maven

- name: Build (ojp-grpc-commons, ojp-jdbc-driver)
run: mvn clean install -pl ojp-grpc-commons,ojp-jdbc-driver -DskipTests

- name: Test (ojp-grpc-commons, ojp-jdbc-driver)
run: mvn test -pl ojp-grpc-commons,ojp-jdbc-driver
3 changes: 3 additions & 0 deletions ojp-grpc-commons/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
</parent>

<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>

<grpc.version>1.73.0</grpc.version>
<os-maven-plugin.version>1.7.1</os-maven-plugin.version>
<lombok.version>1.18.38</lombok.version>
Expand Down
104 changes: 104 additions & 0 deletions ojp-jdbc-driver/dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<artifactId>ojp-parent</artifactId>
<groupId>org.openjdbcproxy</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>ojp-jdbc-driver</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.2.5</version>
<configuration>
<runOrder>alphabetical</runOrder>
</configuration>
</plugin>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>3.5.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>true</createDependencyReducedPom>
<transformers>
<transformer />
<transformer />
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.38</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
<exclusions>
<exclusion>
<artifactId>hamcrest-core</artifactId>
<groupId>org.hamcrest</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>2.3.232</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.12.1</version>
<scope>test</scope>
<exclusions>
<exclusion>
<artifactId>junit-jupiter-api</artifactId>
<groupId>org.junit.jupiter</groupId>
</exclusion>
<exclusion>
<artifactId>junit-jupiter-engine</artifactId>
<groupId>org.junit.jupiter</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>5.12.1</version>
<scope>test</scope>
<exclusions>
<exclusion>
<artifactId>apiguardian-api</artifactId>
<groupId>org.apiguardian</groupId>
</exclusion>
<exclusion>
<artifactId>junit-jupiter-api</artifactId>
<groupId>org.junit.jupiter</groupId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<properties>
<maven.compiler.target>11</maven.compiler.target>
<slf4j.version>2.0.17</slf4j.version>
<maven.compiler.source>11</maven.compiler.source>
</properties>
</project>
3 changes: 3 additions & 0 deletions ojp-jdbc-driver/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
</parent>

<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>

<slf4j.version>2.0.17</slf4j.version>
</properties>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,9 @@ public void onNext(LobReference lobReference) {

@Override
public void onError(Throwable throwable) {
if (throwable instanceof StatusRuntimeException sre) {
if (throwable instanceof StatusRuntimeException) {
try {
StatusRuntimeException sre = (StatusRuntimeException) throwable;
handle(sre);//To convert to SQLException if possible
sfFirstLobReference.setException(sre);
sfFinalLobReference.setException(sre); //When conversion to SQLException not possible
Expand Down Expand Up @@ -334,8 +335,8 @@ public void onCompleted() {

//Wait to receive at least one successful block before returning.
if (!sfFirstBlockReceived.get() && errorReceived[0] != null) {
if (errorReceived[0] instanceof Exception e) {
throw e;
if (errorReceived[0] instanceof Exception) {
throw (Exception) errorReceived[0];
} else {
throw new RuntimeException(errorReceived[0]);
}
Expand Down Expand Up @@ -401,9 +402,9 @@ public void onNext(SessionTerminationStatus sessionTerminationStatus) {
@Override
public void onError(Throwable throwable) {
Throwable t = throwable;
if (throwable instanceof StatusRuntimeException sre) {
if (throwable instanceof StatusRuntimeException) {
try {
handle(sre);
handle((StatusRuntimeException) throwable);
} catch (SQLException e) {
t = e;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ public LobDataBlock next() {
if (this.error != null) {
throw new RuntimeException(this.error);
}
LobDataBlock block = this.blocksReceived.getFirst();
this.blocksReceived.removeFirst();
LobDataBlock block = this.blocksReceived.get(0);
this.blocksReceived.remove(0);
return block;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import java.sql.Time;
import java.sql.Timestamp;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Iterator;
Expand Down Expand Up @@ -108,7 +109,7 @@ public ResultSet executeQuery() throws SQLException {
this.checkClosed();
log.info("Executing query for -> {}", this.sql);
Iterator<OpResult> itOpResult = this.statementService
.executeQuery(this.connection.getSession(), this.sql, this.paramsMap.values().stream().toList(), this.properties);
.executeQuery(this.connection.getSession(), this.sql, new ArrayList<>(this.paramsMap.values()), this.properties);
return new ResultSet(itOpResult, this.statementService, this);
}

Expand All @@ -117,7 +118,7 @@ public int executeUpdate() throws SQLException {
this.checkClosed();
log.info("Executing update for -> {}", this.sql);
OpResult result = this.statementService.executeUpdate(this.connection.getSession(), this.sql,
this.paramsMap.values().stream().toList(), this.getStatementUUID(), null);
new ArrayList<>(this.paramsMap.values()), this.getStatementUUID(), null);
this.connection.setSession(result.getSession());
return deserialize(result.getValue().toByteArray(), Integer.class);
}
Expand All @@ -129,7 +130,7 @@ public void addBatch() throws SQLException {
Map<String, Object> properties = new HashMap<>();
properties.put(CommonConstants.PREPARED_STATEMENT_ADD_BATCH_FLAG, Boolean.TRUE);
OpResult result = this.statementService.executeUpdate(this.connection.getSession(), this.sql,
this.paramsMap.values().stream().toList(), this.getStatementUUID(), properties);
new ArrayList<>(this.paramsMap.values()), this.getStatementUUID(), properties);
this.connection.setSession(result.getSession());
if (StringUtils.isBlank(this.getStatementUUID()) && ResultType.UUID_STRING.equals(result.getType()) &&
!result.getValue().isEmpty()) {
Expand Down Expand Up @@ -752,7 +753,7 @@ private <T> T callProxy(CallType callType, String targetName, Class<?> returnTyp
);
CallResourceResponse response = this.statementService.callResource(reqBuilder.build());
this.connection.setSession(response.getSession());
if (this.getStatementUUID() == null && !response.getResourceUUID().isBlank()) {
if (this.getStatementUUID() == null && StringUtils.isNotBlank(response.getResourceUUID())) {
this.setStatementUUID(response.getResourceUUID());
}
if (Void.class.equals(returnType)) {
Expand Down
Loading