diff --git a/.github/scripts/check-google-java-format.sh b/.github/scripts/check-google-java-format.sh
new file mode 100755
index 0000000000..8e12296a74
--- /dev/null
+++ b/.github/scripts/check-google-java-format.sh
@@ -0,0 +1,45 @@
+#!/bin/bash
+set -u
+
+script_name=""
+
+case "$(uname -sr)" in
+
+ Darwin*)
+ script_name="google-java-format_darwin-arm64"
+ ;;
+
+ Linux*)
+ script_name="google-java-format_linux-x86-64"
+ ;;
+ *)
+ echo 'Unsupported OS'
+ exit 1
+ ;;
+esac
+
+JAVA_FILES=$(find . -name "*.java" -type f)
+
+invalid_files=0
+
+echo "Following files are formatted incorrectly:";
+# TODO: remove '--skip-reflowing-long-strings' once https://github.com/google/google-java-format/issues/566 is fixed
+for FILE in $JAVA_FILES; do
+ if [[ "$*" == *--fix* ]]; then
+ ./$script_name --skip-reflowing-long-strings --replace "$FILE" > /dev/null
+ else
+ ./$script_name --set-exit-if-changed --skip-reflowing-long-strings "$FILE" > /dev/null
+ fi
+ if [ $? -ne 0 ]; then
+ echo "$FILE"
+ ((invalid_files++))
+ fi
+done
+
+if [ "$invalid_files" -ne 0 ]; then
+ echo "Found $invalid_files incorrectly formatted files (listed above), run google-java-format to fix them.";
+ exit 1
+else
+ echo "All files are formatted correctly."
+fi
+
diff --git a/.github/scripts/download_reports.sh b/.github/scripts/download_reports.sh
deleted file mode 100644
index 79e93f818c..0000000000
--- a/.github/scripts/download_reports.sh
+++ /dev/null
@@ -1,41 +0,0 @@
-TMPDIR="test"
-mkdir $TMPDIR
-
-REPO="allegro/hermes"
-BUILDS_FILE="builds.json"
-PAST_BUILDS="$TMPDIR/$BUILDS_FILE"
-
-UNIT_TEST_ARTIFACT="check-test-report"
-E2E_REPORT_ARTIFACT="integrationTest-test-report"
-
-gh run list --repo $REPO --branch master --workflow ci --json "status,databaseId" --limit 20 >> $PAST_BUILDS
-
-cd $TMPDIR
-
-jq -c '.[]' "$BUILDS_FILE" | while read i; do
- STATUS=$(echo $i | jq '.status')
- if [[ "$STATUS" == 'completed' ]]; then
- continue
- fi
- RUN_ID=$(echo $i | jq '.databaseId')
-
- echo "downloading results for run: $RUN_ID"
- RUN_DIR=$RUN_ID
-
- mkdir $RUN_DIR
- echo "creating dir $RUN_DIR"
- cd $RUN_DIR
-
- mkdir $UNIT_TEST_ARTIFACT
- cd $UNIT_TEST_ARTIFACT
- gh run download --repo $REPO -n $UNIT_TEST_ARTIFACT $RUN_ID
- echo "Downloaded unit test report"
- cd ..
-
- mkdir $E2E_REPORT_ARTIFACT
- cd $E2E_REPORT_ARTIFACT
- gh run download --repo $REPO -n $E2E_REPORT_ARTIFACT $RUN_ID
- echo "Downloaded integrationTest report"
-
- cd ../..
-done
diff --git a/.github/scripts/reporter.py b/.github/scripts/reporter.py
deleted file mode 100755
index 5e124b1471..0000000000
--- a/.github/scripts/reporter.py
+++ /dev/null
@@ -1,118 +0,0 @@
-import dataclasses
-import os
-import sys
-from typing import List, Set, Dict
-import xml.etree.ElementTree as ET
-
-
-@dataclasses.dataclass
-class TestResults:
- failed: Set[str]
- passed: Set[str]
- run_id: str
- test_cnt: int = 0
- skipped_cnt: int = 0
- failed_cnt: int = 0
- error_cnt: int = 0
-
-
-def get_test_files(dir: str) -> List[str]:
- files = [
- os.path.join(dp, f)
- for dp, dn, filenames in os.walk(dir)
- for f in filenames
- if os.path.splitext(f)[1] == '.xml'
- and os.path.splitext(f)[0].startswith("TEST-")
- ]
- return files
-
-
-def parse_test_file(file: str, run_id: str) -> TestResults:
- root = ET.parse(file).getroot()
- result = TestResults(
- skipped_cnt=int(root.get("skipped")),
- test_cnt=int(root.get("tests")),
- failed_cnt=int(root.get("failures")),
- error_cnt=int(root.get("errors")),
- failed=set(),
- passed=set(),
- run_id=run_id
- )
- name = root.get("name")
- name = '.'.join(name.split('.')[4:]) # remove common prefix
-
- for testcase in root.findall("testcase"):
- testname = testcase.get("name")
- test_failed = testcase.findall("failure")
- if test_failed:
- result.failed.add(f"{name}#{testname}")
- else:
- result.passed.add(f"{name}#{testname}")
- return result
-
-
-def aggregate_results(test_dir: str, run_id: str) -> TestResults:
- test_files = get_test_files(test_dir)
- results = []
- for test_file in test_files:
- result = parse_test_file(test_file, run_id)
- results.append(result)
-
- agg = TestResults(set(), set(), run_id)
-
- for result in results:
- agg.test_cnt += result.test_cnt
- agg.skipped_cnt += result.skipped_cnt
- agg.error_cnt += result.error_cnt
- agg.failed_cnt += result.failed_cnt
- for fail in result.failed:
- agg.failed.add(fail)
- for pas in result.passed:
- agg.passed.add(pas)
- return agg
-
-
-def report(type: str, runs: List[TestResults]) -> str:
- failed = {}
- markdown = ""
- for run in runs:
- for fail in run.failed:
- if fail in failed:
- failed[fail]["count"] += 1
- failed[fail]["runs"].append(run.run_id)
- else:
- failed[fail] = {"count": 1, "runs": [run.run_id]}
- markdown += f"## {type} \n"
- markdown += "| Test name | Fail count | Failed in runs |\n"
- markdown += "|--|--|--|\n"
- for k, v in sorted(failed.items(), key=lambda item: -item[1]["count"]):
- markdown += f"| {k} | {v['count']} | {v['runs']} |\n"
- markdown += "\n"
- return markdown
-
-
-if __name__ == '__main__':
- root = sys.argv[1]
- print(f"Parsing tests results from directory: {root}")
- run_dirs = [f.path for f in os.scandir(root) if f.is_dir()]
- print(f"Found {len(run_dirs)} run dirs")
- unittest_runs = []
- e2e_runs = []
-
- for run in run_dirs:
- run_id = os.path.basename(os.path.normpath(run))
- unit_test_dir = os.path.join(run, "check-test-report")
- unit_test_results = aggregate_results(unit_test_dir, run_id)
- unittest_runs.append(unit_test_results)
-
- e2e_test_dir = os.path.join(run, "integrationTest-test-report")
- e2e_test_results = aggregate_results(e2e_test_dir, run_id)
- e2e_runs.append(e2e_test_results)
-
- step_summary = "# Failing tests report\n"
- step_summary += report("Unit tests", unittest_runs)
- step_summary += report("Integration tests", e2e_runs)
-
- result_file = os.environ["GITHUB_STEP_SUMMARY"]
- with open(result_file, 'w') as f:
- f.write(step_summary)
diff --git a/.github/workflows/checkstyle.yml b/.github/workflows/checkstyle.yml
deleted file mode 100644
index 42f4ad6dc6..0000000000
--- a/.github/workflows/checkstyle.yml
+++ /dev/null
@@ -1,37 +0,0 @@
-name: Checkstyle
-
-on:
- push:
- branches: [ master ]
- pull_request:
- branches: [ master ]
-
-jobs:
- checkstyle:
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v4
- with:
- fetch-depth: 0
- - uses: reviewdog/action-setup@v1
- with:
- reviewdog_version: latest
- - name: Set up JDK 17
- uses: actions/setup-java@v4
- with:
- java-version: 17
- distribution: 'temurin'
- - name: Setup Gradle
- uses: gradle/gradle-build-action@v2
- - name: Run check style
- # ignore lengthy console setup tasks
- run: ./gradlew --continue clean checkstyleMain checkstyleTest checkstyleIntegrationTest checkstyleSlowIntegrationTest checkstyleJmh -PmaxCheckstyleWarnings=0 -x attachHermesConsole -x prepareIndexTemplate
- - name: Run reviewdog
- if: ${{ success() || failure() }}
- env:
- REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: |
- for f in $(find . -regex '.*/build/reports/checkstyle/.*\.xml'); do
- module_name=$(echo "$f" | cut -d "/" -f2)
- reviewdog -f=checkstyle -level=warning -filter-mode=nofilter -reporter=github-check -name="checkstyle-$module_name" < $f
- done
diff --git a/.github/workflows/google-java-format.yml b/.github/workflows/google-java-format.yml
new file mode 100644
index 0000000000..2ec1c5bf8b
--- /dev/null
+++ b/.github/workflows/google-java-format.yml
@@ -0,0 +1,26 @@
+name: Google java format
+
+on:
+ workflow_dispatch:
+ pull_request:
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+ ref: ${{ github.head_ref }}
+
+ - name: Download and run google java format
+ run: |
+ ls -la
+ curl -sSLO "https://github.com/google/google-java-format/releases/download/v$VERSION/google-java-format_linux-x86-64"
+ chmod a+x google-java-format_linux-x86-64
+ ./.github/scripts/check-google-java-format.sh
+ shell: bash
+ env:
+ VERSION: 1.23.0
+
diff --git a/.github/workflows/test_report.yml b/.github/workflows/test_report.yml
deleted file mode 100644
index 20d78c3a41..0000000000
--- a/.github/workflows/test_report.yml
+++ /dev/null
@@ -1,22 +0,0 @@
-name: "Test report"
-on:
- push:
- branches: [ master ]
-
-jobs:
- validation:
- name: "Test report"
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v4
- - name: Grant execute permission for report downloader
- run: chmod +x ./.github/scripts/download_reports.sh
- - name: Download past reports
- run: ./.github/scripts/download_reports.sh
- env:
- GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- - uses: actions/setup-python@v5
- with:
- python-version: '3.10'
- - name: Aggregate reports
- run: python ./.github/scripts/reporter.py "test"
diff --git a/.gitignore b/.gitignore
index d085ce8969..475005bac9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,7 +1,6 @@
build
.gradle
classes
-.idea
*.iml
*.ipr
*.iws
@@ -39,3 +38,38 @@ scripts/lib/
scripts/pip-selfcheck.json
.DS_Store
+
+# User-specific stuff
+.idea/**/workspace.xml
+.idea/**/tasks.xml
+.idea/**/usage.statistics.xml
+.idea/**/dictionaries
+.idea/**/shelf
+
+# Generated files
+.idea/**/contentModel.xml
+
+# Sensitive or high-churn files
+.idea/**/dataSources/
+.idea/**/dataSources.ids
+.idea/**/dataSources.local.xml
+.idea/**/sqlDataSources.xml
+.idea/**/dynamic.xml
+.idea/**/uiDesigner.xml
+.idea/**/dbnavigator.xml
+
+
+# Gradle and Maven with auto-import
+# When using Gradle or Maven with auto-import, you should exclude module files,
+# since they will be recreated, and may cause churn. Uncomment if using
+# auto-import.
+.idea/artifacts
+.idea/compiler.xml
+.idea/jarRepositories.xml
+.idea/modules.xml
+.idea/*.iml
+.idea/modules
+
+# Gradle
+.idea/**/gradle.xml
+.idea/**/libraries
diff --git a/.idea/externalDependencies.xml b/.idea/externalDependencies.xml
new file mode 100644
index 0000000000..679f74ca17
--- /dev/null
+++ b/.idea/externalDependencies.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/google-java-format.xml b/.idea/google-java-format.xml
new file mode 100644
index 0000000000..8b57f4527a
--- /dev/null
+++ b/.idea/google-java-format.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000000..4336a05b15
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,58 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000000..35eb1ddfbb
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/README.md b/README.md
index 9b0545b9c9..eadb83bfd6 100644
--- a/README.md
+++ b/README.md
@@ -20,3 +20,40 @@ If you have any question or idea regarding the project, please feel free to reac
## License
**hermes** is published under [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0).
+
+## Development
+
+### Code formatting
+For code formatting we use [google-java-format](https://github.com/google/google-java-format/tree/master).
+Following steps are required for optimal dev experience in IJ:
+
+1. Download [google-java-format plugin](https://plugins.jetbrains.com/plugin/8527-google-java-format)
+2. [Set custom VM options required for IJ plugin](https://github.com/google/google-java-format/tree/master?tab=readme-ov-file#intellij-jre-config)
+3. Go to `Settings > google-java-format` and click `Enable google java-format` (should be checked by default)
+4. Go to `Settings > Tools > Actions on Save` and enable `Reformat code` and `Optimize imports` for Java files
+
+Each save should automatically trigger reformat.
+
+If you want to debug the CLI check on macOS:
+
+```shell
+wget https://github.com/google/google-java-format/releases/download/v1.23.0/google-java-format_darwin-arm64
+chmod a+x google-java-format_darwin-arm64
+chmod a+x .github/scripts/check-google-java-format.sh
+./.github/scripts/check-google-java-format.sh
+```
+
+or if you are on Linux:
+
+```shell
+wget https://github.com/google/google-java-format/releases/download/v1.23.0/google-java-format_linux-x86-64
+chmod a+x google-java-format_linux-x86-64
+chmod a+x .github/scripts/check-google-java-format.sh
+./.github/scripts/check-google-java-format.sh
+```
+
+You can also run the following command to fix formatting for the whole project:
+
+```shell
+./.github/scripts/check-google-java-format.sh --fix
+```
diff --git a/build.gradle b/build.gradle
index b1b59aa29f..02f86f4e6d 100644
--- a/build.gradle
+++ b/build.gradle
@@ -39,7 +39,6 @@ nexusPublishing {
allprojects {
apply plugin: 'java'
apply plugin: 'groovy'
- apply plugin: 'checkstyle'
group = 'pl.allegro.tech.hermes'
version = scmVersion.version
@@ -206,18 +205,6 @@ subprojects {
events 'passed', 'skipped', 'failed'
}
}
-
- tasks.withType(Checkstyle) {
- reports {
- xml.required = true
- html.required = false
- }
- }
-
- checkstyle {
- toolVersion '10.3.4'
- maxWarnings getIntProperty('maxCheckstyleWarnings', Integer.MAX_VALUE)
- }
}
def getIntProperty(String name, int defaultValue) {
diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml
deleted file mode 100644
index 06c50058df..0000000000
--- a/config/checkstyle/checkstyle.xml
+++ /dev/null
@@ -1,439 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/config/checkstyle/suppressions.xml b/config/checkstyle/suppressions.xml
deleted file mode 100644
index 0375f028d1..0000000000
--- a/config/checkstyle/suppressions.xml
+++ /dev/null
@@ -1,56 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/hermes-api/src/main/java/pl/allegro/tech/hermes/api/Anonymizable.java b/hermes-api/src/main/java/pl/allegro/tech/hermes/api/Anonymizable.java
index ca360e371d..272b8ccccb 100644
--- a/hermes-api/src/main/java/pl/allegro/tech/hermes/api/Anonymizable.java
+++ b/hermes-api/src/main/java/pl/allegro/tech/hermes/api/Anonymizable.java
@@ -1,5 +1,5 @@
package pl.allegro.tech.hermes.api;
public interface Anonymizable {
- Anonymizable anonymize();
+ Anonymizable anonymize();
}
diff --git a/hermes-api/src/main/java/pl/allegro/tech/hermes/api/AvroMediaType.java b/hermes-api/src/main/java/pl/allegro/tech/hermes/api/AvroMediaType.java
index 165befe5a7..6d1faa8844 100644
--- a/hermes-api/src/main/java/pl/allegro/tech/hermes/api/AvroMediaType.java
+++ b/hermes-api/src/main/java/pl/allegro/tech/hermes/api/AvroMediaType.java
@@ -2,7 +2,7 @@
public class AvroMediaType {
- public static final String AVRO_BINARY = "avro/binary";
+ public static final String AVRO_BINARY = "avro/binary";
- public static final String AVRO_JSON = "avro/json";
+ public static final String AVRO_JSON = "avro/json";
}
diff --git a/hermes-api/src/main/java/pl/allegro/tech/hermes/api/BatchSubscriptionPolicy.java b/hermes-api/src/main/java/pl/allegro/tech/hermes/api/BatchSubscriptionPolicy.java
index 1c06f0ee03..79b26f3bb5 100644
--- a/hermes-api/src/main/java/pl/allegro/tech/hermes/api/BatchSubscriptionPolicy.java
+++ b/hermes-api/src/main/java/pl/allegro/tech/hermes/api/BatchSubscriptionPolicy.java
@@ -3,202 +3,208 @@
import com.fasterxml.jackson.annotation.JsonCreator;
import com.google.common.base.MoreObjects;
import jakarta.validation.constraints.Min;
-import pl.allegro.tech.hermes.api.helpers.Patch;
-
import java.util.Map;
import java.util.Objects;
+import pl.allegro.tech.hermes.api.helpers.Patch;
public class BatchSubscriptionPolicy {
- private static final int DEFAULT_MESSAGE_TTL = 60;
- private static final int DEFAULT_MESSAGE_BACKOFF = 500;
- private static final int DEFAULT_REQUEST_TIMEOUT = 30 * 1000;
- private static final int DEFAULT_BATCH_SIZE = 100;
- private static final int DEFAULT_BATCH_TIME = 30 * 1000;
- private static final int DEFAULT_BATCH_VOLUME = 64 * 1000;
-
- @Min(0)
- private int messageTtl;
-
- private boolean retryClientErrors;
-
- @Min(0)
- private int messageBackoff;
-
- @Min(1)
- private int requestTimeout;
-
- @Min(1)
- private int batchSize;
-
- @Min(1)
- private int batchTime;
-
- @Min(1)
- private int batchVolume;
-
- private BatchSubscriptionPolicy() {}
-
- public BatchSubscriptionPolicy(int messageTtl,
- boolean retryClientErrors,
- int messageBackoff,
- int requestTimeout,
- int batchSize,
- int batchTime,
- int batchVolume) {
- this.messageTtl = messageTtl;
- this.retryClientErrors = retryClientErrors;
- this.messageBackoff = messageBackoff;
- this.requestTimeout = requestTimeout;
- this.batchSize = batchSize;
- this.batchTime = batchTime;
- this.batchVolume = batchVolume;
+ private static final int DEFAULT_MESSAGE_TTL = 60;
+ private static final int DEFAULT_MESSAGE_BACKOFF = 500;
+ private static final int DEFAULT_REQUEST_TIMEOUT = 30 * 1000;
+ private static final int DEFAULT_BATCH_SIZE = 100;
+ private static final int DEFAULT_BATCH_TIME = 30 * 1000;
+ private static final int DEFAULT_BATCH_VOLUME = 64 * 1000;
+
+ @Min(0)
+ private int messageTtl;
+
+ private boolean retryClientErrors;
+
+ @Min(0)
+ private int messageBackoff;
+
+ @Min(1)
+ private int requestTimeout;
+
+ @Min(1)
+ private int batchSize;
+
+ @Min(1)
+ private int batchTime;
+
+ @Min(1)
+ private int batchVolume;
+
+ private BatchSubscriptionPolicy() {}
+
+ public BatchSubscriptionPolicy(
+ int messageTtl,
+ boolean retryClientErrors,
+ int messageBackoff,
+ int requestTimeout,
+ int batchSize,
+ int batchTime,
+ int batchVolume) {
+ this.messageTtl = messageTtl;
+ this.retryClientErrors = retryClientErrors;
+ this.messageBackoff = messageBackoff;
+ this.requestTimeout = requestTimeout;
+ this.batchSize = batchSize;
+ this.batchTime = batchTime;
+ this.batchVolume = batchVolume;
+ }
+
+ @JsonCreator
+ public static BatchSubscriptionPolicy create(Map properties) {
+ return new BatchSubscriptionPolicy(
+ (Integer) properties.getOrDefault("messageTtl", DEFAULT_MESSAGE_TTL),
+ (Boolean) properties.getOrDefault("retryClientErrors", false),
+ (Integer) properties.getOrDefault("messageBackoff", DEFAULT_MESSAGE_BACKOFF),
+ (Integer) properties.getOrDefault("requestTimeout", DEFAULT_REQUEST_TIMEOUT),
+ (Integer) properties.getOrDefault("batchSize", DEFAULT_BATCH_SIZE),
+ (Integer) properties.getOrDefault("batchTime", DEFAULT_BATCH_TIME),
+ (Integer) properties.getOrDefault("batchVolume", DEFAULT_BATCH_VOLUME));
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(
+ messageTtl,
+ retryClientErrors,
+ messageBackoff,
+ requestTimeout,
+ batchSize,
+ batchTime,
+ batchVolume);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
}
-
- @JsonCreator
- public static BatchSubscriptionPolicy create(Map properties) {
- return new BatchSubscriptionPolicy(
- (Integer) properties.getOrDefault("messageTtl", DEFAULT_MESSAGE_TTL),
- (Boolean) properties.getOrDefault("retryClientErrors", false),
- (Integer) properties.getOrDefault("messageBackoff", DEFAULT_MESSAGE_BACKOFF),
- (Integer) properties.getOrDefault("requestTimeout", DEFAULT_REQUEST_TIMEOUT),
- (Integer) properties.getOrDefault("batchSize", DEFAULT_BATCH_SIZE),
- (Integer) properties.getOrDefault("batchTime", DEFAULT_BATCH_TIME),
- (Integer) properties.getOrDefault("batchVolume", DEFAULT_BATCH_VOLUME)
- );
+ if (obj == null || getClass() != obj.getClass()) {
+ return false;
+ }
+ final BatchSubscriptionPolicy other = (BatchSubscriptionPolicy) obj;
+ return Objects.equals(this.messageTtl, other.messageTtl)
+ && Objects.equals(this.retryClientErrors, other.retryClientErrors)
+ && Objects.equals(this.messageBackoff, other.messageBackoff)
+ && Objects.equals(this.requestTimeout, other.requestTimeout)
+ && Objects.equals(this.batchSize, other.batchSize)
+ && Objects.equals(this.batchTime, other.batchTime)
+ && Objects.equals(this.batchVolume, other.batchVolume);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(this)
+ .add("messageTtl", messageTtl)
+ .add("messageBackoff", messageBackoff)
+ .add("retryClientErrors", retryClientErrors)
+ .add("batchSize", batchSize)
+ .add("batchTime", batchTime)
+ .add("batchVolume", batchVolume)
+ .add("requestTimeout", requestTimeout)
+ .toString();
+ }
+
+ public Integer getMessageTtl() {
+ return messageTtl;
+ }
+
+ public Integer getMessageBackoff() {
+ return messageBackoff;
+ }
+
+ public Boolean isRetryClientErrors() {
+ return retryClientErrors;
+ }
+
+ public Integer getBatchSize() {
+ return batchSize;
+ }
+
+ public Integer getBatchTime() {
+ return batchTime;
+ }
+
+ public Integer getBatchVolume() {
+ return batchVolume;
+ }
+
+ public Integer getRequestTimeout() {
+ return requestTimeout;
+ }
+
+ public static class Builder {
+
+ private BatchSubscriptionPolicy subscriptionPolicy;
+
+ public static Builder batchSubscriptionPolicy() {
+ return new Builder();
}
- @Override
- public int hashCode() {
- return Objects.hash(messageTtl, retryClientErrors, messageBackoff, requestTimeout, batchSize, batchTime, batchVolume);
+ public Builder() {
+ subscriptionPolicy = new BatchSubscriptionPolicy();
}
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null || getClass() != obj.getClass()) {
- return false;
- }
- final BatchSubscriptionPolicy other = (BatchSubscriptionPolicy) obj;
- return Objects.equals(this.messageTtl, other.messageTtl)
- && Objects.equals(this.retryClientErrors, other.retryClientErrors)
- && Objects.equals(this.messageBackoff, other.messageBackoff)
- && Objects.equals(this.requestTimeout, other.requestTimeout)
- && Objects.equals(this.batchSize, other.batchSize)
- && Objects.equals(this.batchTime, other.batchTime)
- && Objects.equals(this.batchVolume, other.batchVolume);
+ public Builder withMessageTtl(int messageTtl) {
+ subscriptionPolicy.messageTtl = messageTtl;
+ return this;
}
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("messageTtl", messageTtl)
- .add("messageBackoff", messageBackoff)
- .add("retryClientErrors", retryClientErrors)
- .add("batchSize", batchSize)
- .add("batchTime", batchTime)
- .add("batchVolume", batchVolume)
- .add("requestTimeout", requestTimeout)
- .toString();
+ public Builder withMessageBackoff(int messageBackoff) {
+ subscriptionPolicy.messageBackoff = messageBackoff;
+ return this;
}
- public Integer getMessageTtl() {
- return messageTtl;
+ public Builder withClientErrorRetry(boolean retryClientErrors) {
+ subscriptionPolicy.retryClientErrors = retryClientErrors;
+ return this;
}
- public Integer getMessageBackoff() {
- return messageBackoff;
+ public Builder withBatchSize(int batchSize) {
+ subscriptionPolicy.batchSize = batchSize;
+ return this;
}
- public Boolean isRetryClientErrors() {
- return retryClientErrors;
+ public Builder withBatchTime(int batchTime) {
+ subscriptionPolicy.batchTime = batchTime;
+ return this;
}
- public Integer getBatchSize() {
- return batchSize;
+ public Builder withBatchVolume(int batchVolume) {
+ subscriptionPolicy.batchVolume = batchVolume;
+ return this;
}
- public Integer getBatchTime() {
- return batchTime;
+ public Builder withRequestTimeout(int requestTimeout) {
+ subscriptionPolicy.requestTimeout = requestTimeout;
+ return this;
}
- public Integer getBatchVolume() {
- return batchVolume;
+ public BatchSubscriptionPolicy build() {
+ return new BatchSubscriptionPolicy(
+ subscriptionPolicy.messageTtl,
+ subscriptionPolicy.retryClientErrors,
+ subscriptionPolicy.messageBackoff,
+ subscriptionPolicy.requestTimeout,
+ subscriptionPolicy.batchSize,
+ subscriptionPolicy.batchTime,
+ subscriptionPolicy.batchVolume);
}
- public Integer getRequestTimeout() {
- return requestTimeout;
+ public Builder applyDefaults() {
+ return this;
}
- public static class Builder {
-
- private BatchSubscriptionPolicy subscriptionPolicy;
-
- public static Builder batchSubscriptionPolicy() {
- return new Builder();
- }
-
- public Builder() {
- subscriptionPolicy = new BatchSubscriptionPolicy();
- }
-
- public Builder withMessageTtl(int messageTtl) {
- subscriptionPolicy.messageTtl = messageTtl;
- return this;
- }
-
- public Builder withMessageBackoff(int messageBackoff) {
- subscriptionPolicy.messageBackoff = messageBackoff;
- return this;
- }
-
- public Builder withClientErrorRetry(boolean retryClientErrors) {
- subscriptionPolicy.retryClientErrors = retryClientErrors;
- return this;
- }
-
- public Builder withBatchSize(int batchSize) {
- subscriptionPolicy.batchSize = batchSize;
- return this;
- }
-
- public Builder withBatchTime(int batchTime) {
- subscriptionPolicy.batchTime = batchTime;
- return this;
- }
-
- public Builder withBatchVolume(int batchVolume) {
- subscriptionPolicy.batchVolume = batchVolume;
- return this;
- }
-
- public Builder withRequestTimeout(int requestTimeout) {
- subscriptionPolicy.requestTimeout = requestTimeout;
- return this;
- }
-
- public BatchSubscriptionPolicy build() {
- return new BatchSubscriptionPolicy(
- subscriptionPolicy.messageTtl,
- subscriptionPolicy.retryClientErrors,
- subscriptionPolicy.messageBackoff,
- subscriptionPolicy.requestTimeout,
- subscriptionPolicy.batchSize,
- subscriptionPolicy.batchTime,
- subscriptionPolicy.batchVolume);
- }
-
- public Builder applyDefaults() {
- return this;
- }
-
- public Builder applyPatch(PatchData patch) {
- if (patch != null) {
- subscriptionPolicy = Patch.apply(subscriptionPolicy, patch);
- }
- return this;
- }
+ public Builder applyPatch(PatchData patch) {
+ if (patch != null) {
+ subscriptionPolicy = Patch.apply(subscriptionPolicy, patch);
+ }
+ return this;
}
+ }
}
diff --git a/hermes-api/src/main/java/pl/allegro/tech/hermes/api/BlacklistStatus.java b/hermes-api/src/main/java/pl/allegro/tech/hermes/api/BlacklistStatus.java
index 8be8d8d53b..250b9a54f5 100644
--- a/hermes-api/src/main/java/pl/allegro/tech/hermes/api/BlacklistStatus.java
+++ b/hermes-api/src/main/java/pl/allegro/tech/hermes/api/BlacklistStatus.java
@@ -2,39 +2,38 @@
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
-
import java.util.Objects;
public final class BlacklistStatus {
- public static final BlacklistStatus BLACKLISTED = new BlacklistStatus(true);
- public static final BlacklistStatus NOT_BLACKLISTED = new BlacklistStatus(false);
+ public static final BlacklistStatus BLACKLISTED = new BlacklistStatus(true);
+ public static final BlacklistStatus NOT_BLACKLISTED = new BlacklistStatus(false);
- private final boolean blacklisted;
+ private final boolean blacklisted;
- @JsonCreator
- private BlacklistStatus(@JsonProperty("blacklisted") boolean blacklisted) {
- this.blacklisted = blacklisted;
- }
+ @JsonCreator
+ private BlacklistStatus(@JsonProperty("blacklisted") boolean blacklisted) {
+ this.blacklisted = blacklisted;
+ }
- public boolean isBlacklisted() {
- return blacklisted;
- }
+ public boolean isBlacklisted() {
+ return blacklisted;
+ }
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- BlacklistStatus that = (BlacklistStatus) o;
- return blacklisted == that.blacklisted;
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
}
-
- @Override
- public int hashCode() {
- return Objects.hash(blacklisted);
+ if (o == null || getClass() != o.getClass()) {
+ return false;
}
+ BlacklistStatus that = (BlacklistStatus) o;
+ return blacklisted == that.blacklisted;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(blacklisted);
+ }
}
diff --git a/hermes-api/src/main/java/pl/allegro/tech/hermes/api/Constraints.java b/hermes-api/src/main/java/pl/allegro/tech/hermes/api/Constraints.java
index 60d71c6e40..fcf82f100a 100644
--- a/hermes-api/src/main/java/pl/allegro/tech/hermes/api/Constraints.java
+++ b/hermes-api/src/main/java/pl/allegro/tech/hermes/api/Constraints.java
@@ -3,37 +3,36 @@
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import jakarta.validation.constraints.Min;
-
import java.util.Objects;
public class Constraints {
- @Min(1)
- private final int consumersNumber;
+ @Min(1)
+ private final int consumersNumber;
- @JsonCreator
- public Constraints(@JsonProperty("consumersNumber") int consumersNumber) {
- this.consumersNumber = consumersNumber;
- }
+ @JsonCreator
+ public Constraints(@JsonProperty("consumersNumber") int consumersNumber) {
+ this.consumersNumber = consumersNumber;
+ }
- public int getConsumersNumber() {
- return consumersNumber;
- }
+ public int getConsumersNumber() {
+ return consumersNumber;
+ }
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- Constraints that = (Constraints) o;
- return consumersNumber == that.consumersNumber;
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
}
-
- @Override
- public int hashCode() {
- return Objects.hash(consumersNumber);
+ if (o == null || getClass() != o.getClass()) {
+ return false;
}
+ Constraints that = (Constraints) o;
+ return consumersNumber == that.consumersNumber;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(consumersNumber);
+ }
}
diff --git a/hermes-api/src/main/java/pl/allegro/tech/hermes/api/ConsumerGroup.java b/hermes-api/src/main/java/pl/allegro/tech/hermes/api/ConsumerGroup.java
index d7acd8e37e..61528237df 100644
--- a/hermes-api/src/main/java/pl/allegro/tech/hermes/api/ConsumerGroup.java
+++ b/hermes-api/src/main/java/pl/allegro/tech/hermes/api/ConsumerGroup.java
@@ -2,62 +2,62 @@
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
-
import java.util.Objects;
import java.util.Set;
public class ConsumerGroup {
- private final String clusterName;
- private final String groupId;
- private final String state;
-
- private final Set members;
-
- @JsonCreator
- public ConsumerGroup(@JsonProperty("clusterName") String clusterName,
- @JsonProperty("groupId") String groupId,
- @JsonProperty("state") String state,
- @JsonProperty("members") Set members) {
- this.clusterName = clusterName;
- this.groupId = groupId;
- this.state = state;
- this.members = members;
- }
-
- public String getClusterName() {
- return clusterName;
- }
-
- public String getGroupId() {
- return groupId;
- }
-
- public String getState() {
- return state;
- }
-
- public Set getMembers() {
- return members;
+ private final String clusterName;
+ private final String groupId;
+ private final String state;
+
+ private final Set members;
+
+ @JsonCreator
+ public ConsumerGroup(
+ @JsonProperty("clusterName") String clusterName,
+ @JsonProperty("groupId") String groupId,
+ @JsonProperty("state") String state,
+ @JsonProperty("members") Set members) {
+ this.clusterName = clusterName;
+ this.groupId = groupId;
+ this.state = state;
+ this.members = members;
+ }
+
+ public String getClusterName() {
+ return clusterName;
+ }
+
+ public String getGroupId() {
+ return groupId;
+ }
+
+ public String getState() {
+ return state;
+ }
+
+ public Set getMembers() {
+ return members;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
}
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- ConsumerGroup that = (ConsumerGroup) o;
- return Objects.equals(clusterName, that.clusterName)
- && Objects.equals(groupId, that.groupId)
- && Objects.equals(state, that.state)
- && Objects.equals(members, that.members);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(clusterName, groupId, state, members);
+ if (o == null || getClass() != o.getClass()) {
+ return false;
}
+ ConsumerGroup that = (ConsumerGroup) o;
+ return Objects.equals(clusterName, that.clusterName)
+ && Objects.equals(groupId, that.groupId)
+ && Objects.equals(state, that.state)
+ && Objects.equals(members, that.members);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(clusterName, groupId, state, members);
+ }
}
diff --git a/hermes-api/src/main/java/pl/allegro/tech/hermes/api/ConsumerGroupMember.java b/hermes-api/src/main/java/pl/allegro/tech/hermes/api/ConsumerGroupMember.java
index 62348cb9b6..94d0491b9d 100644
--- a/hermes-api/src/main/java/pl/allegro/tech/hermes/api/ConsumerGroupMember.java
+++ b/hermes-api/src/main/java/pl/allegro/tech/hermes/api/ConsumerGroupMember.java
@@ -2,61 +2,61 @@
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
-
import java.util.Objects;
import java.util.Set;
public class ConsumerGroupMember {
- private final String consumerId;
- private final String clientId;
- private final String host;
-
- private final Set partitions;
-
- @JsonCreator
- public ConsumerGroupMember(@JsonProperty("consumerId") String consumerId,
- @JsonProperty("clientId") String clientId,
- @JsonProperty("host")String host,
- @JsonProperty("partitions") Set partitions) {
- this.consumerId = consumerId;
- this.clientId = clientId;
- this.host = host;
- this.partitions = partitions;
- }
-
- public String getConsumerId() {
- return consumerId;
- }
-
- public String getClientId() {
- return clientId;
- }
-
- public String getHost() {
- return host;
- }
-
- public Set getPartitions() {
- return partitions;
+ private final String consumerId;
+ private final String clientId;
+ private final String host;
+
+ private final Set partitions;
+
+ @JsonCreator
+ public ConsumerGroupMember(
+ @JsonProperty("consumerId") String consumerId,
+ @JsonProperty("clientId") String clientId,
+ @JsonProperty("host") String host,
+ @JsonProperty("partitions") Set partitions) {
+ this.consumerId = consumerId;
+ this.clientId = clientId;
+ this.host = host;
+ this.partitions = partitions;
+ }
+
+ public String getConsumerId() {
+ return consumerId;
+ }
+
+ public String getClientId() {
+ return clientId;
+ }
+
+ public String getHost() {
+ return host;
+ }
+
+ public Set getPartitions() {
+ return partitions;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
}
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- ConsumerGroupMember that = (ConsumerGroupMember) o;
- return Objects.equals(consumerId, that.consumerId)
- && Objects.equals(clientId, that.clientId)
- && Objects.equals(host, that.host)
- && Objects.equals(partitions, that.partitions);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(consumerId, clientId, host, partitions);
+ if (o == null || getClass() != o.getClass()) {
+ return false;
}
+ ConsumerGroupMember that = (ConsumerGroupMember) o;
+ return Objects.equals(consumerId, that.consumerId)
+ && Objects.equals(clientId, that.clientId)
+ && Objects.equals(host, that.host)
+ && Objects.equals(partitions, that.partitions);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(consumerId, clientId, host, partitions);
+ }
}
diff --git a/hermes-api/src/main/java/pl/allegro/tech/hermes/api/ContentType.java b/hermes-api/src/main/java/pl/allegro/tech/hermes/api/ContentType.java
index 383f1cdf47..1980a07a1e 100644
--- a/hermes-api/src/main/java/pl/allegro/tech/hermes/api/ContentType.java
+++ b/hermes-api/src/main/java/pl/allegro/tech/hermes/api/ContentType.java
@@ -1,5 +1,6 @@
package pl.allegro.tech.hermes.api;
public enum ContentType {
- JSON, AVRO
+ JSON,
+ AVRO
}
diff --git a/hermes-api/src/main/java/pl/allegro/tech/hermes/api/DatacenterReadiness.java b/hermes-api/src/main/java/pl/allegro/tech/hermes/api/DatacenterReadiness.java
index 88f12af28a..279bffc33e 100644
--- a/hermes-api/src/main/java/pl/allegro/tech/hermes/api/DatacenterReadiness.java
+++ b/hermes-api/src/main/java/pl/allegro/tech/hermes/api/DatacenterReadiness.java
@@ -2,56 +2,52 @@
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
-
import java.util.Objects;
public class DatacenterReadiness {
- private final String datacenter;
- private final ReadinessStatus status;
-
- @JsonCreator
- public DatacenterReadiness(@JsonProperty("datacenter") String datacenter,
- @JsonProperty("status") ReadinessStatus status) {
- this.datacenter = datacenter;
- this.status = status;
- }
-
- public String getDatacenter() {
- return datacenter;
- }
-
- public ReadinessStatus getStatus() {
- return status;
- }
-
- @Override
- public String toString() {
- return "DatacenterReadiness{"
- + "datacenter='" + datacenter + '\''
- + ", status=" + status
- + '}';
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (!(o instanceof DatacenterReadiness)) {
- return false;
- }
- DatacenterReadiness that = (DatacenterReadiness) o;
- return status == that.status
- && Objects.equals(datacenter, that.datacenter);
+ private final String datacenter;
+ private final ReadinessStatus status;
+
+ @JsonCreator
+ public DatacenterReadiness(
+ @JsonProperty("datacenter") String datacenter,
+ @JsonProperty("status") ReadinessStatus status) {
+ this.datacenter = datacenter;
+ this.status = status;
+ }
+
+ public String getDatacenter() {
+ return datacenter;
+ }
+
+ public ReadinessStatus getStatus() {
+ return status;
+ }
+
+ @Override
+ public String toString() {
+ return "DatacenterReadiness{" + "datacenter='" + datacenter + '\'' + ", status=" + status + '}';
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
}
-
- @Override
- public int hashCode() {
- return Objects.hash(datacenter, status);
- }
-
- public enum ReadinessStatus {
- READY,
- NOT_READY
+ if (!(o instanceof DatacenterReadiness)) {
+ return false;
}
+ DatacenterReadiness that = (DatacenterReadiness) o;
+ return status == that.status && Objects.equals(datacenter, that.datacenter);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(datacenter, status);
+ }
+
+ public enum ReadinessStatus {
+ READY,
+ NOT_READY
+ }
}
diff --git a/hermes-api/src/main/java/pl/allegro/tech/hermes/api/DeliveryType.java b/hermes-api/src/main/java/pl/allegro/tech/hermes/api/DeliveryType.java
index 9edad2adb3..ade2c08947 100644
--- a/hermes-api/src/main/java/pl/allegro/tech/hermes/api/DeliveryType.java
+++ b/hermes-api/src/main/java/pl/allegro/tech/hermes/api/DeliveryType.java
@@ -1,5 +1,6 @@
package pl.allegro.tech.hermes.api;
public enum DeliveryType {
- SERIAL, BATCH
+ SERIAL,
+ BATCH
}
diff --git a/hermes-api/src/main/java/pl/allegro/tech/hermes/api/EndpointAddress.java b/hermes-api/src/main/java/pl/allegro/tech/hermes/api/EndpointAddress.java
index 140a932de1..0dfdeacff9 100644
--- a/hermes-api/src/main/java/pl/allegro/tech/hermes/api/EndpointAddress.java
+++ b/hermes-api/src/main/java/pl/allegro/tech/hermes/api/EndpointAddress.java
@@ -5,145 +5,145 @@
import com.google.common.base.MoreObjects;
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
-import pl.allegro.tech.hermes.api.jackson.EndpointAddressDeserializer;
-import pl.allegro.tech.hermes.api.jackson.EndpointAddressSerializer;
-
import java.net.URI;
import java.util.Objects;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import pl.allegro.tech.hermes.api.jackson.EndpointAddressDeserializer;
+import pl.allegro.tech.hermes.api.jackson.EndpointAddressSerializer;
@JsonDeserialize(using = EndpointAddressDeserializer.class)
@JsonSerialize(using = EndpointAddressSerializer.class)
public class EndpointAddress implements Anonymizable {
- private static final String ANONYMIZED_PASSWORD = "*****";
+ private static final String ANONYMIZED_PASSWORD = "*****";
- private static final Pattern URL_PATTERN = Pattern.compile("([a-zA-Z0-9]*)://(([a-zA-Z0-9\\.\\~\\-\\_]*):(.*)@)?(.*)");
+ private static final Pattern URL_PATTERN =
+ Pattern.compile("([a-zA-Z0-9]*)://(([a-zA-Z0-9\\.\\~\\-\\_]*):(.*)@)?(.*)");
- private static final int PROTOCOL_GROUP = 1;
+ private static final int PROTOCOL_GROUP = 1;
- private static final int ADDRESS_GROUP = 5;
+ private static final int ADDRESS_GROUP = 5;
- private static final int USER_INFO_GROUP = 2;
+ private static final int USER_INFO_GROUP = 2;
- private static final int USERNAME_GROUP = 3;
+ private static final int USERNAME_GROUP = 3;
- private static final int PASSWORD_GROUP = 4;
+ private static final int PASSWORD_GROUP = 4;
- private final boolean containsCredentials;
+ private final boolean containsCredentials;
- private final String protocol;
+ private final String protocol;
- private final String username;
+ private final String username;
- private final String password;
+ private final String password;
- private final String endpoint;
+ private final String endpoint;
- private final String rawEndpoint;
+ private final String rawEndpoint;
- public EndpointAddress(String endpoint) {
- this.rawEndpoint = endpoint;
+ public EndpointAddress(String endpoint) {
+ this.rawEndpoint = endpoint;
- Matcher matcher = URL_PATTERN.matcher(endpoint);
- if (matcher.matches()) {
- this.protocol = matcher.group(PROTOCOL_GROUP);
- this.containsCredentials = !Strings.isNullOrEmpty(matcher.group(USER_INFO_GROUP));
+ Matcher matcher = URL_PATTERN.matcher(endpoint);
+ if (matcher.matches()) {
+ this.protocol = matcher.group(PROTOCOL_GROUP);
+ this.containsCredentials = !Strings.isNullOrEmpty(matcher.group(USER_INFO_GROUP));
- this.username = containsCredentials ? matcher.group(USERNAME_GROUP) : null;
- this.password = containsCredentials ? matcher.group(PASSWORD_GROUP) : null;
+ this.username = containsCredentials ? matcher.group(USERNAME_GROUP) : null;
+ this.password = containsCredentials ? matcher.group(PASSWORD_GROUP) : null;
- this.endpoint = containsCredentials ? protocol + "://" + matcher.group(ADDRESS_GROUP) : endpoint;
- } else {
- this.protocol = null;
- this.containsCredentials = false;
- this.username = null;
- this.password = null;
- this.endpoint = endpoint;
- }
+ this.endpoint =
+ containsCredentials ? protocol + "://" + matcher.group(ADDRESS_GROUP) : endpoint;
+ } else {
+ this.protocol = null;
+ this.containsCredentials = false;
+ this.username = null;
+ this.password = null;
+ this.endpoint = endpoint;
}
+ }
- private EndpointAddress(String protocol, String endpoint, String username) {
- this.protocol = protocol;
- this.endpoint = endpoint;
- this.containsCredentials = true;
- this.username = username;
- this.password = ANONYMIZED_PASSWORD;
+ private EndpointAddress(String protocol, String endpoint, String username) {
+ this.protocol = protocol;
+ this.endpoint = endpoint;
+ this.containsCredentials = true;
+ this.username = username;
+ this.password = ANONYMIZED_PASSWORD;
- this.rawEndpoint = protocol + "://" + username + ":" + password + "@" + endpoint.replace(protocol + "://", "");
- }
+ this.rawEndpoint =
+ protocol + "://" + username + ":" + password + "@" + endpoint.replace(protocol + "://", "");
+ }
- public static EndpointAddress of(String endpoint) {
- return new EndpointAddress(endpoint);
- }
+ public static EndpointAddress of(String endpoint) {
+ return new EndpointAddress(endpoint);
+ }
- public static EndpointAddress of(URI endpoint) {
- return new EndpointAddress(endpoint.toString());
- }
+ public static EndpointAddress of(URI endpoint) {
+ return new EndpointAddress(endpoint.toString());
+ }
- public static String extractProtocolFromAddress(String endpoint) {
- Preconditions.checkArgument(endpoint.indexOf(':') != -1);
+ public static String extractProtocolFromAddress(String endpoint) {
+ Preconditions.checkArgument(endpoint.indexOf(':') != -1);
- return endpoint.substring(0, endpoint.indexOf(':'));
- }
+ return endpoint.substring(0, endpoint.indexOf(':'));
+ }
- public String getEndpoint() {
- return endpoint;
- }
+ public String getEndpoint() {
+ return endpoint;
+ }
- public String getRawEndpoint() {
- return rawEndpoint;
- }
+ public String getRawEndpoint() {
+ return rawEndpoint;
+ }
- public URI getUri() {
- return URI.create(endpoint);
- }
+ public URI getUri() {
+ return URI.create(endpoint);
+ }
- public String getProtocol() {
- return protocol;
- }
+ public String getProtocol() {
+ return protocol;
+ }
- @Override
- public int hashCode() {
- return Objects.hash(rawEndpoint);
- }
+ @Override
+ public int hashCode() {
+ return Objects.hash(rawEndpoint);
+ }
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null || getClass() != obj.getClass()) {
- return false;
- }
- final EndpointAddress other = (EndpointAddress) obj;
- return Objects.equals(this.rawEndpoint, other.rawEndpoint);
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
}
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("endpoint", endpoint)
- .toString();
+ if (obj == null || getClass() != obj.getClass()) {
+ return false;
}
+ final EndpointAddress other = (EndpointAddress) obj;
+ return Objects.equals(this.rawEndpoint, other.rawEndpoint);
+ }
- public boolean containsCredentials() {
- return containsCredentials;
- }
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(this).add("endpoint", endpoint).toString();
+ }
- public String getPassword() {
- return password;
- }
+ public boolean containsCredentials() {
+ return containsCredentials;
+ }
- public String getUsername() {
- return username;
- }
+ public String getPassword() {
+ return password;
+ }
- public EndpointAddress anonymize() {
- if (containsCredentials) {
- return new EndpointAddress(protocol, endpoint, username);
- }
- return this;
- }
+ public String getUsername() {
+ return username;
+ }
+
+ public EndpointAddress anonymize() {
+ if (containsCredentials) {
+ return new EndpointAddress(protocol, endpoint, username);
+ }
+ return this;
+ }
}
diff --git a/hermes-api/src/main/java/pl/allegro/tech/hermes/api/EndpointAddressResolverMetadata.java b/hermes-api/src/main/java/pl/allegro/tech/hermes/api/EndpointAddressResolverMetadata.java
index 8cd3f20bd8..cf863ee8d9 100644
--- a/hermes-api/src/main/java/pl/allegro/tech/hermes/api/EndpointAddressResolverMetadata.java
+++ b/hermes-api/src/main/java/pl/allegro/tech/hermes/api/EndpointAddressResolverMetadata.java
@@ -7,7 +7,6 @@
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
import com.google.common.collect.ImmutableMap;
import jakarta.validation.constraints.NotNull;
-
import java.io.IOException;
import java.util.Collections;
import java.util.HashMap;
@@ -15,81 +14,84 @@
import java.util.Objects;
import java.util.Optional;
-@JsonSerialize(using = EndpointAddressResolverMetadata.EndpointAddressResolverMetadataSerializer.class)
+@JsonSerialize(
+ using = EndpointAddressResolverMetadata.EndpointAddressResolverMetadataSerializer.class)
public class EndpointAddressResolverMetadata {
- private static final EndpointAddressResolverMetadata EMPTY_INSTANCE = new EndpointAddressResolverMetadata(Collections.emptyMap());
+ private static final EndpointAddressResolverMetadata EMPTY_INSTANCE =
+ new EndpointAddressResolverMetadata(Collections.emptyMap());
- @NotNull
- private Map entries;
+ @NotNull private Map entries;
- @JsonCreator
- public EndpointAddressResolverMetadata(Map entries) {
- this.entries = ImmutableMap.copyOf(entries);
- }
+ @JsonCreator
+ public EndpointAddressResolverMetadata(Map entries) {
+ this.entries = ImmutableMap.copyOf(entries);
+ }
- public static EndpointAddressResolverMetadata empty() {
- return EMPTY_INSTANCE;
- }
+ public static EndpointAddressResolverMetadata empty() {
+ return EMPTY_INSTANCE;
+ }
- public static Builder endpointAddressResolverMetadata() {
- return new Builder();
- }
+ public static Builder endpointAddressResolverMetadata() {
+ return new Builder();
+ }
- public Optional