Skip to content

Make error field final in OrasException#3

Open
sonarqube-agent[bot] wants to merge 1 commit into
mainfrom
remediate-main-20260610-071929-e3bd3b16
Open

Make error field final in OrasException#3
sonarqube-agent[bot] wants to merge 1 commit into
mainfrom
remediate-main-20260610-071929-e3bd3b16

Conversation

@sonarqube-agent

Copy link
Copy Markdown

This PR was created because a team member assigned these issues to the Remediation Agent.

Added the final modifier to the error field in the OrasException class to ensure the exception's state is immutable after construction. This addresses a SonarQube issue and follows best practices for exception classes by preventing accidental modification of error field state.

View Project in SonarCloud


Fixed Issues

java:S1165 - Make this "error" field final. • MINORView issue

Location: src/main/java/land/oras/exception/OrasException.java:45

Why is this an issue?

When a class has all final fields, the compiler ensures that the object’s state remains constant. It also enforces a clear design intent of immutability, making the class easier to reason about and use correctly.

What changed

This hunk directly fixes the static analysis warning about the error field in the OrasException class not being final. By adding the final modifier to the error field, the exception class's state becomes immutable after construction, which is the recommended practice for exception classes.

--- a/src/main/java/land/oras/exception/OrasException.java
+++ b/src/main/java/land/oras/exception/OrasException.java
@@ -45,1 +45,1 @@ public class OrasException extends RuntimeException {
-    private @Nullable Error error;
+    private final @Nullable Error error;

Have a suggestion or found an issue? Share your feedback here.


SonarQube Remediation Agent uses AI. Check for mistakes.

Fixed issues:
- AZ6wRBe-Qw83x_y7ZeLz for java:S1165 rule

Generated by SonarQube Agent (task: 8cc3afcb-c255-4063-96cb-ce961daa529f)
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant