diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml index 74c83d9..8d27bf6 100644 --- a/.github/workflows/maven-publish.yml +++ b/.github/workflows/maven-publish.yml @@ -34,20 +34,32 @@ jobs: echo "REVISION=$REVISION" >> $GITHUB_ENV echo "IMPLEMENTATION_NAME=$IMPLEMENTATION_NAME" >> $GITHUB_ENV - - name: Set up JDK 17 + - name: Set up JDK 17 (Snapshot) + if: ${{ !startsWith(github.ref, 'refs/tags/v') }} + uses: actions/setup-java@v1 + with: + java-version: 17 + server-id: mchv-snapshot-distribution + server-username: MAVEN_USERNAME + server-password: MAVEN_PASSWORD + - name: Build (Snapshot) + if: ${{ !startsWith(github.ref, 'refs/tags/v') }} + shell: bash + run: | + echo "IMPLEMENTATION_NAME: $IMPLEMENTATION_NAME" + + source ./scripts/continuous-integration/github-workflows/deploy-snapshot.sh + env: + MAVEN_USERNAME: ${{ secrets.MCHV_USERNAME }} + MAVEN_PASSWORD: ${{ secrets.MCHV_TOKEN }} + - name: Set up JDK 17 (Release) + if: ${{ startsWith(github.ref, 'refs/tags/v') }} uses: actions/setup-java@v1 with: java-version: 17 server-id: mchv-release-distribution server-username: MAVEN_USERNAME server-password: MAVEN_PASSWORD - - name: Build - if: ${{ !startsWith(github.ref, 'refs/tags/v') }} - shell: bash - run: | - echo "IMPLEMENTATION_NAME: $IMPLEMENTATION_NAME" - - source ./scripts/continuous-integration/github-workflows/only-compile-release.sh - name: Deploy to Maven (Release) if: ${{ startsWith(github.ref, 'refs/tags/v') }} shell: bash diff --git a/scripts/continuous-integration/github-workflows/deploy-snapshot.sh b/scripts/continuous-integration/github-workflows/deploy-snapshot.sh new file mode 100644 index 0000000..14b060f --- /dev/null +++ b/scripts/continuous-integration/github-workflows/deploy-snapshot.sh @@ -0,0 +1,10 @@ +#!/bin/bash -e +set -e +# OTHER REQUIRED ENVIRONMENT VARIABLES: +# IMPLEMENTATION_NAME = + +cd ./scripts/core/ +./deploy_snapshot.sh + +echo "Done." +exit 0 diff --git a/scripts/core/deploy_snapshot.sh b/scripts/core/deploy_snapshot.sh new file mode 100755 index 0000000..2bfadd3 --- /dev/null +++ b/scripts/core/deploy_snapshot.sh @@ -0,0 +1,16 @@ +#!/bin/bash -e +# OTHER REQUIRED ENVIRONMENT VARIABLES: +# IMPLEMENTATION_NAME = + +# Check variables correctness +if [ -z "${IMPLEMENTATION_NAME}" ]; then + echo "Missing parameter: IMPLEMENTATION_NAME" + exit 1 +fi + +cd ../../ + +mvn -B -P "${IMPLEMENTATION_NAME}" clean deploy + +echo "Done." +exit 0 diff --git a/src/main/java/it/tdlight/common/internal/ResponseReceiver.java b/src/main/java/it/tdlight/common/internal/ResponseReceiver.java index b86f0b7..12f5dc0 100644 --- a/src/main/java/it/tdlight/common/internal/ResponseReceiver.java +++ b/src/main/java/it/tdlight/common/internal/ResponseReceiver.java @@ -110,6 +110,8 @@ public final class ResponseReceiver extends Thread implements AutoCloseable { } cleanClientEventsArray(lastClientIdEventsCount); + assert areBoundsValid(clientEvents, 0, lastClientIdEventsCount); + eventsHandler.handleClientEvents(clientId, lastClientClosed, clientEventIds, @@ -198,6 +200,18 @@ public final class ResponseReceiver extends Thread implements AutoCloseable { } } + private boolean areBoundsValid(Object[] clientEvents, int start, int length) { + if (start > length) { + return false; + } + for (int i = start; i < length; i++) { + if (clientEvents[i] == null) { + return false; + } + } + return true; + } + private void cleanEventsArray(int eventsCount) { if (eventsLastUsedLength > eventsCount) { Arrays.fill(events, eventsCount, eventsLastUsedLength, null);