Skip to content

Restore ExceptionFactory#281

Merged
alexander-yevsyukov merged 18 commits intomasterfrom
restore-exception-factory
Mar 25, 2026
Merged

Restore ExceptionFactory#281
alexander-yevsyukov merged 18 commits intomasterfrom
restore-exception-factory

Conversation

@alexander-yevsyukov
Copy link
Copy Markdown
Collaborator

@alexander-yevsyukov alexander-yevsyukov commented Mar 24, 2026

This PR restores the ExceptionFactory class which was accidentally deleted in one of the previous PRs. This PR also adds tests to ensure that this abstract class is used via stub implementation.

Other notable changes

  • The ViolationText class was moved out of the diags subpackage to the upper level so that we don't have the one-class package.
  • Previously deprecated types from the io.spine.option package were removed.
  • Dependencies on Base, ToolBase, Validation, Compiler, and KSP were updated.
  • ExceptionFactory.getMessageTypeAttribute() now accepts parameter of the generic type M instead of just Message.

Copilot AI review requested due to automatic review settings March 24, 2026 19:37
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Restores the previously removed ExceptionFactory in the JVM runtime, updates diagnostics packaging by moving ViolationText to the top-level validation package, removes deprecated runtime option types, and bumps project/dependency versions accordingly.

Changes:

  • Reintroduce ExceptionFactory and add tests (with stub implementations) to validate its behavior.
  • Move ViolationText out of the diags subpackage and adjust call sites/imports.
  • Remove deprecated io.spine.validation.option runtime option types and update dependency versions/reports.

Reviewed changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
version.gradle.kts Bumps published Validation SDK version to 2.0.0-SNAPSHOT.407.
tests/runtime/src/test/kotlin/io/spine/validation/ValidateUtilitySpec.kt Removes outdated ViolationText import after package move.
pom.xml Updates project and dependency versions (incl. Spine/Compiler/KSP/Protobuf).
jvm-runtime/src/test/kotlin/io/spine/validation/given/ExceptionFactoryStubs.kt Adds stub ExceptionFactory/exception used by tests.
jvm-runtime/src/test/kotlin/io/spine/validation/diags/ViolationTextSpec.kt Updates import to new ViolationText package.
jvm-runtime/src/test/kotlin/io/spine/validation/ExceptionFactorySpec.kt Adds coverage asserting exception/error contents produced by ExceptionFactory.
jvm-runtime/src/main/java/io/spine/validation/option/ValidatingOption.java Removes deprecated runtime option API.
jvm-runtime/src/main/java/io/spine/validation/option/Required.java Removes deprecated runtime option implementation.
jvm-runtime/src/main/java/io/spine/validation/option/FieldValidatingOption.java Removes deprecated runtime option base type.
jvm-runtime/src/main/java/io/spine/validation/option/AlwaysRequired.java Removes deprecated runtime option specialization.
jvm-runtime/src/main/java/io/spine/validation/diags/package-info.java Removes diags package metadata as the package is eliminated.
jvm-runtime/src/main/java/io/spine/validation/ViolationText.java Moves ViolationText into io.spine.validation.
jvm-runtime/src/main/java/io/spine/validation/ValidationException.java Adjusts ViolationText usage and adds serialVersionUID.
jvm-runtime/src/main/java/io/spine/validation/ExceptionFactory.java Restores the abstract factory for building validation exceptions/errors.
dependencies.md Updates generated dependency/license report to the new versions.
buildSrc/src/main/kotlin/io/spine/dependency/local/Validation.kt Bumps referenced Validation dependency version to ...406.
buildSrc/src/main/kotlin/io/spine/dependency/local/ToolBase.kt Bumps ToolBase versions to ...375.
buildSrc/src/main/kotlin/io/spine/dependency/local/Compiler.kt Bumps Compiler fallback versions to ...041.
buildSrc/src/main/kotlin/io/spine/dependency/local/Base.kt Bumps Spine Base versions to ...386.
buildSrc/src/main/kotlin/io/spine/dependency/build/Ksp.kt Bumps KSP version to 2.3.6.
Comments suppressed due to low confidence (1)

jvm-runtime/src/main/java/io/spine/validation/ViolationText.java:28

  • Moving ViolationText from io.spine.validation.diags to io.spine.validation is a binary/source breaking change for any consumers importing the old package. If backward compatibility is still desired for this SNAPSHOT line, consider keeping a deprecated shim in io.spine.validation.diags (e.g., a delegating wrapper with the same static API) so existing code continues to compile while users migrate.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread jvm-runtime/src/main/java/io/spine/validation/ExceptionFactory.java
Comment thread jvm-runtime/src/main/java/io/spine/validation/ExceptionFactory.java Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot AI review requested due to automatic review settings March 25, 2026 14:25
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 19 out of 20 changed files in this pull request and generated 5 comments.

Files not reviewed (1)
  • .idea/inspectionProfiles/Project_Default.xml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


package io.spine.validation.given

import com.google.protobuf.Message
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

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

com.google.protobuf.Message is imported but never used in this test stub, which can fail the build if Kotlin warnings are treated as errors. Please remove the unused import.

Suggested change
import com.google.protobuf.Message

Copilot uses AI. Check for mistakes.
* the type of the {@code Message}, typically it would be a grouping interface such as
* {@link io.spine.base.EventMessage} or {@link io.spine.base.CommandMessage}
* @param <C>
* the type of the {@linkplain io.spine.type.MessageClass} of {@code |M|}
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

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

Javadoc for type parameter C contains {@code |M|}, which looks like a formatting artifact and will render incorrectly. Replace it with the intended reference (e.g. {@code M}) so the generated docs are correct.

Suggested change
* the type of the {@linkplain io.spine.type.MessageClass} of {@code |M|}
* the type of the {@linkplain io.spine.type.MessageClass} of {@code M}

Copilot uses AI. Check for mistakes.
Comment on lines +70 to +72
* an invalid event message
* @param violations
* constraint violations for the event message
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

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

Constructor parameter docs refer to an “event message”, but ExceptionFactory is generic over any invalid Message type (including commands). Please update the wording to avoid misleading API docs.

Suggested change
* an invalid event message
* @param violations
* constraint violations for the event message
* an invalid message
* @param violations
* constraint violations for the message

Copilot uses AI. Check for mistakes.
protected abstract Map<String, Value> getMessageTypeAttribute(M message);

/**
* Defines the way to create an instance of exception basing on the source {@code Message},
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

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

The phrase “create an instance of exception basing on…” is grammatically incorrect and makes the Javadoc harder to read. Please reword it (e.g. “based on”).

Suggested change
* Defines the way to create an instance of exception basing on the source {@code Message},
* Defines how to create an exception instance based on the source {@code Message},

Copilot uses AI. Check for mistakes.
Comment on lines +258 to +269
<inspection_tool class="FieldNamingConvention" enabled="true" level="WARNING" enabled_by_default="true">
<extension name="ConstantNamingConvention" enabled="false">
<option name="m_regex" value="[A-Z_\d]*" />
<option name="m_minLength" value="5" />
<option name="m_maxLength" value="32" />
</extension>
<extension name="InstanceVariableNamingConvention" enabled="true">
<option name="m_regex" value="[a-z][A-Za-z\d]*" />
<option name="m_minLength" value="2" />
<option name="m_maxLength" value="32" />
</extension>
</inspection_tool>
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

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

This PR is primarily about restoring ExceptionFactory and related validation types, but it also changes the IntelliJ inspection profile (e.g., adds FieldNamingConvention). If these IDE settings changes are not strictly required for the restoration, consider moving them to a separate PR to keep review history focused.

Copilot uses AI. Check for mistakes.
@alexander-yevsyukov alexander-yevsyukov merged commit b08a553 into master Mar 25, 2026
7 of 14 checks passed
@alexander-yevsyukov alexander-yevsyukov deleted the restore-exception-factory branch March 25, 2026 15:24
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.

3 participants