Skip to content
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

Feat: new Exception system #44

Merged

Conversation

koptan
Copy link
Contributor

@koptan koptan commented Nov 7, 2023

To Fix #30, also some cleanup in the code.

BREAKING CHANGE: a lot of Exceptions have been added and removed, MIW needs to adopt the new changes.

Description

Pre-review checks

Please ensure to do as many of the following checks as possible, before asking for committer review:

@koptan
Copy link
Contributor Author

koptan commented Nov 24, 2023

@borisrizov-zf please add @bjoern-arnold and @DominikPinsel as reviewer.

@borisrizov-zf
Copy link
Contributor

@koptan We can begin the move after the 23.12 release. You'll have to do a rebase first.

@koptan koptan mentioned this pull request Dec 6, 2023
2 tasks
@koptan
Copy link
Contributor Author

koptan commented Dec 6, 2023

@koptan We can begin the move after the 23.12 release. You'll have to do a rebase first.

This PR, will require some changes from MIW team, so I think it's better to talk to them and ask them to do the migration and test it from their side then we can do the merge.

@borisrizov-zf @DominikPinsel

@koptan koptan closed this Dec 7, 2023
@koptan koptan force-pushed the issue-30-new-system-exception branch from 55fbfc0 to a3ecc34 Compare December 7, 2023 11:14
@koptan koptan reopened this Dec 7, 2023
@borisrizov-zf
Copy link
Contributor

This PR is too large, we'll have to split it up to remain compliant. Let's plan the split next week.

Copy link
Contributor

@bjoern-arnold bjoern-arnold left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better if InvalidPrivateKeyFormatException extend KeyGenerationException. This would eliminate the need to wrap the message in a KeyGenerationException and rethrow it.

Copy link
Contributor

@bjoern-arnold bjoern-arnold left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Creating an exception hierarchy with class KeyGenerationException as parent would be more elegant than wrapping and more specific exceptions in a KeyGenerationException and rethrowing it.
  • Also think about adding a "serialVerionUID" field to all exception classes (see JavaDoc for java.ioSerializable)

@koptan koptan changed the title feat: new Exception system Feat: new Exception system Jan 9, 2024
@borisrizov-zf
Copy link
Contributor

@koptan please fix merge issues. Probably you need to just rebase.

@koptan koptan force-pushed the issue-30-new-system-exception branch from faa875d to 9d6053a Compare January 31, 2024 12:57
Copy link
Contributor

@borisrizov-zf borisrizov-zf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check the comments.


/** The type Invalide private key format. */
public class InvalidPrivateKeyFormatException extends KeyGenerationException {
private static final long serialVersionUID = -3348735256693555408L;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add the @Serial annotation
Make it equal 1L. as it's a new class
Repeat for all new Exception classes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to use this compilation option javac -Xlint:serial to make it work, so I didn't change.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's actually preferable to start at 1L and increment only when you've changed the class, in order to ensure serialization doesn't break between compilers, platforms and other outside factors. For exceptions it is sufficient to set it at 1L

@koptan koptan requested a review from borisrizov-zf February 1, 2024 10:26
.github/workflows/build.yaml Outdated Show resolved Hide resolved
.github/workflows/publish-maven.yaml Outdated Show resolved Hide resolved
.github/workflows/publish-snapshot-maven.yaml Outdated Show resolved Hide resolved
docs/scripts/generateDoc.sh Outdated Show resolved Hide resolved
docs/scripts/generateImages.sh Outdated Show resolved Hide resolved
pom.xml Outdated Show resolved Hide resolved
@koptan koptan requested a review from borisrizov-zf February 6, 2024 14:47
@koptan koptan requested a review from borisrizov-zf February 6, 2024 15:33
@borisrizov-zf
Copy link
Contributor

@koptan I've done another sweep of the PR. It looks good, so as soon as you update the serialVersionUID we can finalize.

@borisrizov-zf borisrizov-zf merged commit cc049f0 into eclipse-tractusx:main Feb 20, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Meaningful / consistent exception system
4 participants