-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
538 propagate exceptions via either and add suppressed #737
Merged
ds-jhartmann
merged 6 commits into
eclipse-tractusx:fix/538-propagate-exceptions-via-Either-and-addSuppressed
from
dsmf:538-propagate-exceptions-via-Either-and-addSuppressed
Jul 8, 2024
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1cb33ca
fix(impl): [#538] propagate exceptions to tombstones using Either and…
dsmf db48632
Update owasp.yml
dsmf 9b01f6c
Merge branch 'main' into 538-propagate-exceptions-via-Either-and-addS…
dsmf 989244d
Merge branch 'main' into 538-propagate-exceptions-via-Either-and-addS…
dsmf e3c272a
Update irs-common/src/main/java/org/eclipse/tractusx/irs/common/util/…
dsmf e4d9216
Update irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/clie…
dsmf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
name: "OWASP dependency scanner" | ||
|
||
on: | ||
workflow_dispatch: # Trigger manually | ||
push: | ||
branches: main | ||
paths-ignore: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
irs-common/src/main/java/org/eclipse/tractusx/irs/common/ExceptionUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/******************************************************************************** | ||
* Copyright (c) 2022,2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) | ||
* Copyright (c) 2021,2024 Contributors to the Eclipse Foundation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Apache License, Version 2.0 which is available at | ||
* https://www.apache.org/licenses/LICENSE-2.0. | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
********************************************************************************/ | ||
package org.eclipse.tractusx.irs.common; | ||
|
||
import java.util.Collection; | ||
|
||
import io.github.resilience4j.core.functions.Either; | ||
|
||
/** | ||
* Utilities for exception handling | ||
*/ | ||
public final class ExceptionUtils { | ||
|
||
private ExceptionUtils() { | ||
// private constructor, utility class | ||
} | ||
|
||
/** | ||
* Adds all exceptions from left side of the given Eithers to the exception. | ||
* | ||
* @param eithers the {@link Either}s | ||
* @param exception the exception | ||
* @param <E> the exception type (left-hand side of {@link Either}) | ||
* @param <T> the object type (right-hand side of {@link Either}) | ||
*/ | ||
public static <E extends Exception, T> void addSuppressedExceptions(final Collection<Either<E, T>> eithers, | ||
final Exception exception) { | ||
for (final Either<E, T> either : eithers) { | ||
if (either.isLeft() && either.getLeft() != null) { | ||
exception.addSuppressed(either.getLeft()); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
irs-common/src/test/java/org/eclipse/tractusx/irs/common/ExceptionUtilsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/******************************************************************************** | ||
* Copyright (c) 2022,2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) | ||
* Copyright (c) 2021,2024 Contributors to the Eclipse Foundation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Apache License, Version 2.0 which is available at | ||
* https://www.apache.org/licenses/LICENSE-2.0. | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
********************************************************************************/ | ||
package org.eclipse.tractusx.irs.common; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import io.github.resilience4j.core.functions.Either; | ||
import org.junit.jupiter.api.Test; | ||
|
||
/** | ||
* Test for class {@link ExceptionUtils} | ||
*/ | ||
class ExceptionUtilsTest { | ||
|
||
@Test | ||
void addSuppressedExceptionsTest() { | ||
|
||
// ARRANGE | ||
final List<Either<Exception, String>> eithers = new ArrayList<>(); | ||
eithers.add(Either.left(new RuntimeException("Some runtime exception"))); | ||
eithers.add(Either.right("Some string")); | ||
eithers.add(Either.left(new IllegalArgumentException("Another exception"))); | ||
eithers.add(Either.left(null)); | ||
|
||
final Exception mainException = new Exception("Main exception"); | ||
|
||
// ACT | ||
ExceptionUtils.addSuppressedExceptions(eithers, mainException); | ||
|
||
// ASSERT | ||
final Throwable[] suppressedExceptions = mainException.getSuppressed(); | ||
assertEquals(2, suppressedExceptions.length); // Expecting two suppressed exceptions | ||
assertEquals("Some runtime exception", suppressedExceptions[0].getMessage()); | ||
assertEquals("Another exception", suppressedExceptions[1].getMessage()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When changing this interface, we need to make sure to document how to use this.
This interface is used by trace-x