diff --git a/.github/workflows/cd-deploy.yml b/.github/workflows/cd-deploy.yml
index 4c987ab..f123d53 100644
--- a/.github/workflows/cd-deploy.yml
+++ b/.github/workflows/cd-deploy.yml
@@ -12,6 +12,8 @@ jobs:
publish:
environment: ${{ inputs.environment }}
runs-on: ubuntu-latest
+ env:
+ MAVEN_ARGS: "--no-transfer-progress"
steps:
- name: Checkout repository
uses: actions/checkout@v6
diff --git a/.github/workflows/cd-integration.yml b/.github/workflows/cd-integration.yml
index 670b6c3..bb91de1 100644
--- a/.github/workflows/cd-integration.yml
+++ b/.github/workflows/cd-integration.yml
@@ -15,6 +15,8 @@ jobs:
variables:
if: ${{ github.event.pull_request.merged == true }}
runs-on: ubuntu-latest
+ env:
+ MAVEN_ARGS: "--no-transfer-progress"
outputs:
version: ${{ steps.environment.outputs.version }}
target-branch: ${{ steps.environment.outputs.target-branch }}
diff --git a/.github/workflows/ci-gates.yml b/.github/workflows/ci-gates.yml
index 9b772c4..e4860d3 100644
--- a/.github/workflows/ci-gates.yml
+++ b/.github/workflows/ci-gates.yml
@@ -7,16 +7,18 @@ jobs:
sonarcloud:
environment: sonarcloud
runs-on: ubuntu-latest
+ env:
+ MAVEN_ARGS: "--no-transfer-progress"
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- - name: Set up JDK 17
+ - name: Set up JDK 21
uses: actions/setup-java@v5
with:
- java-version: 17
+ java-version: 21
distribution: "corretto"
cache: "maven"
diff --git a/.github/workflows/ci-maven.yml b/.github/workflows/ci-maven.yml
index d1572e6..d466f6c 100644
--- a/.github/workflows/ci-maven.yml
+++ b/.github/workflows/ci-maven.yml
@@ -6,6 +6,8 @@ on:
jobs:
build:
runs-on: ubuntu-latest
+ env:
+ MAVEN_ARGS: "--no-transfer-progress"
strategy:
matrix:
java-version: [8, 11, 17, 21, 25]
@@ -32,6 +34,8 @@ jobs:
test:
runs-on: ubuntu-latest
+ env:
+ MAVEN_ARGS: "--no-transfer-progress"
strategy:
matrix:
java-version: [8, 11, 17, 21, 25]
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index a1cdadf..e6ea6a2 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -5,6 +5,7 @@ on:
branches:
- feature/**
- fix/**
+ - dependabot/maven/**
env:
TYPE: ${{ startsWith(github.ref_name, 'feature') && 'Feature' || 'Fix'}}
diff --git a/README.md b/README.md
index 8226aa4..09bdf69 100644
--- a/README.md
+++ b/README.md
@@ -22,7 +22,7 @@ _**Compatible AWS JDK v1 >= 1.12**_
_**Compatible AWS JDK v2 >= 2.18**_
-This library supports **`Kotlin`** aswell
+This library supports **`Kotlin`** as well
## 1. Quick Start
diff --git a/amazon-sqs-java-messaging-lib-template/pom.xml b/amazon-sqs-java-messaging-lib-template/pom.xml
index 42df961..be4fe96 100644
--- a/amazon-sqs-java-messaging-lib-template/pom.xml
+++ b/amazon-sqs-java-messaging-lib-template/pom.xml
@@ -7,7 +7,7 @@
com.github.mvallim
amazon-sqs-java-messaging-lib
- 1.3.1-SNAPSHOT
+ 1.3.2-SNAPSHOT
../pom.xml
diff --git a/amazon-sqs-java-messaging-lib-template/src/main/java/com/amazon/sqs/messaging/lib/core/AbstractAmazonSqsConsumer.java b/amazon-sqs-java-messaging-lib-template/src/main/java/com/amazon/sqs/messaging/lib/core/AbstractAmazonSqsConsumer.java
index 0153825..1ebee09 100644
--- a/amazon-sqs-java-messaging-lib-template/src/main/java/com/amazon/sqs/messaging/lib/core/AbstractAmazonSqsConsumer.java
+++ b/amazon-sqs-java-messaging-lib-template/src/main/java/com/amazon/sqs/messaging/lib/core/AbstractAmazonSqsConsumer.java
@@ -18,8 +18,8 @@
import java.nio.charset.StandardCharsets;
import java.time.Duration;
+import java.util.ArrayList;
import java.util.Collections;
-import java.util.LinkedList;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
@@ -31,7 +31,6 @@
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.locks.LockSupport;
import java.util.function.BiFunction;
import java.util.function.UnaryOperator;
@@ -63,6 +62,7 @@
* @param the publish batch result type
* @param the request entry payload type
*/
+@SuppressWarnings("java:S135")
abstract class AbstractAmazonSqsConsumer implements Runnable, AmazonSqsConsumer {
/**
@@ -278,7 +278,7 @@ private boolean canAddPayload(final int batchSizeBytes) {
@SneakyThrows
private Optional createBatch(final BlockingQueue> requests) {
final AtomicInteger batchSizeBytes = new AtomicInteger(0);
- final List requestEntries = new LinkedList<>();
+ final List requestEntries = new ArrayList<>(queueProperty.getMaxBatchSize());
while (canAddToBatch(batchSizeBytes.get(), requestEntries.size(), requests.peek())) {
final RequestEntry request = requests.peek();
@@ -299,7 +299,8 @@ private Optional createBatch(final BlockingQueue> requests) {
final String stringPayload = new String(payload, StandardCharsets.UTF_8);
- final String message = String.format("The maximum allowed message size exceeding 1024KB (1,048,576 bytes). Payload: %s, Headers: %s", stringPayload, request.getMessageHeaders());
+ final String message = String.format("The maximum allowed message size exceeding 1024KB (1,048,576 bytes). Payload: %s, Headers: %s",
+ stringPayload, request.getMessageHeaders());
handleError(publishBatchRequest, new MaximumAllowedMessageException(message, requests.take()));
@@ -309,8 +310,11 @@ private Optional createBatch(final BlockingQueue> requests) {
continue;
}
- if (canAddPayload(batchSizeBytes.addAndGet(messageSize))) {
+ if (canAddPayload(batchSizeBytes.get() + messageSize)) {
requestEntries.add(requestEntryInternalFactory.create(requests.take(), payload));
+ batchSizeBytes.addAndGet(messageSize);
+ } else {
+ break;
}
}
@@ -337,8 +341,13 @@ private Optional createBatch(final BlockingQueue> requests) {
@SneakyThrows
public CompletableFuture await() {
return CompletableFuture.runAsync(() -> {
- while (MapUtils.isNotEmpty(this.pendingRequests) || CollectionUtils.isNotEmpty(this.queueRequests)) {
- LockSupport.parkNanos(Duration.ofMillis(queueProperty.getLinger()).toNanos());
+ while (MapUtils.isNotEmpty(pendingRequests) || CollectionUtils.isNotEmpty(queueRequests)) {
+ try {
+ TimeUnit.NANOSECONDS.sleep(Duration.ofMillis(queueProperty.getLinger()).toNanos());
+ } catch (final InterruptedException e) {
+ Thread.currentThread().interrupt();
+ LOGGER.warn("await() interrupted");
+ }
}
});
}
diff --git a/amazon-sqs-java-messaging-lib-template/src/main/java/com/amazon/sqs/messaging/lib/core/AbstractAmazonSqsProducer.java b/amazon-sqs-java-messaging-lib-template/src/main/java/com/amazon/sqs/messaging/lib/core/AbstractAmazonSqsProducer.java
index c0ac684..c71657a 100644
--- a/amazon-sqs-java-messaging-lib-template/src/main/java/com/amazon/sqs/messaging/lib/core/AbstractAmazonSqsProducer.java
+++ b/amazon-sqs-java-messaging-lib-template/src/main/java/com/amazon/sqs/messaging/lib/core/AbstractAmazonSqsProducer.java
@@ -38,7 +38,7 @@
@RequiredArgsConstructor(access = AccessLevel.PROTECTED)
abstract class AbstractAmazonSqsProducer implements AmazonSqsProducer {
- private final AtomicReference state = new AtomicReference<>(State.RUNNIG);
+ private final AtomicReference state = new AtomicReference<>(State.RUNNING);
private final ConcurrentMap> pendingRequests;
@@ -53,7 +53,7 @@ abstract class AbstractAmazonSqsProducer implements AmazonSqsProducer {
@Override
@SneakyThrows
public ListenableFuture send(final RequestEntry requestEntry) {
- if (State.RUNNIG.equals(state.get())) {
+ if (State.RUNNING.equals(state.get())) {
return enqueueRequest(requestEntry);
} else {
final ListenableFutureImpl listenableFutureImpl = new ListenableFutureImpl();
@@ -75,7 +75,7 @@ public ListenableFuture send(final Requ
*/
@Override
public void shutdown() {
- state.compareAndSet(State.RUNNIG, State.SHUTDOWN);
+ state.compareAndSet(State.RUNNING, State.SHUTDOWN);
}
/**
@@ -96,7 +96,7 @@ private ListenableFuture enqueueRequest
* Lifecycle states of the producer.
*/
enum State {
- RUNNIG, SHUTDOWN
+ RUNNING, SHUTDOWN
}
}
\ No newline at end of file
diff --git a/amazon-sqs-java-messaging-lib-v1/pom.xml b/amazon-sqs-java-messaging-lib-v1/pom.xml
index c649d6a..ed09618 100644
--- a/amazon-sqs-java-messaging-lib-v1/pom.xml
+++ b/amazon-sqs-java-messaging-lib-v1/pom.xml
@@ -7,7 +7,7 @@
com.github.mvallim
amazon-sqs-java-messaging-lib
- 1.3.1-SNAPSHOT
+ 1.3.2-SNAPSHOT
../pom.xml
diff --git a/amazon-sqs-java-messaging-lib-v2/pom.xml b/amazon-sqs-java-messaging-lib-v2/pom.xml
index f713ee8..a48db35 100644
--- a/amazon-sqs-java-messaging-lib-v2/pom.xml
+++ b/amazon-sqs-java-messaging-lib-v2/pom.xml
@@ -7,7 +7,7 @@
com.github.mvallim
amazon-sqs-java-messaging-lib
- 1.3.1-SNAPSHOT
+ 1.3.2-SNAPSHOT
../pom.xml
diff --git a/pom.xml b/pom.xml
index 2c997b6..a87abbb 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
com.github.mvallim
amazon-sqs-java-messaging-lib
- 1.3.1-SNAPSHOT
+ 1.3.2-SNAPSHOT
pom
${project.artifactId}