Skip to content

Migrate context package to Kotlin #104

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

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

alexander-yevsyukov
Copy link
Contributor

No description provided.

Copy link
Contributor

@Copilot 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

This PR migrates the context package from Java to Kotlin and updates the API to use AutoCloseable instead of the deprecated LoggingContextCloseable. Key changes include version bumps in build files, API signature adjustments in context-related classes and tests, and refactoring of context installation methods for consistency.

Reviewed Changes

Copilot reviewed 25 out of 25 changed files in this pull request and generated no comments.

Show a summary per file
File Description
version.gradle.kts, pom.xml, dependencies.md Version update from "2.0.0-SNAPSHOT.255" to "2.0.0-SNAPSHOT.256"
LoggingContextFactory.kt Changed property access to a method call (getContextApiSingleton()) to reflect API migration.
ScopedLoggingContextSpec.kt Updated test assertions and signatures to use AutoCloseable instead of LoggingContextCloseable, and refined parameter nullability.
StdContextDataProvider.kt, GrpcScopedLoggingContext.{java,kt} Refactored context builder installation methods to return AutoCloseable, ensuring consistency across implementations.
Various files (ContextDataProvider.kt, Platform.kt, ScopedLoggingContexts.java) Updated API calls and comments to align with the new Kotlin implementation and updated lifecycle management.
Comments suppressed due to low confidence (5)

logging/src/jvmMain/kotlin/io/spine/logging/context/LoggingContextFactory.kt:57

  • Ensure that the usage of getContextApiSingleton() as a method call is consistent with the new API design for retrieving the context instance.
        val context = JContextDataProvider.getInstance().getContextApiSingleton().newContext()

jvm/middleware/src/test/kotlin/io/spine/logging/jvm/context/ScopedLoggingContextSpec.kt:77

  • The return type has been updated from LoggingContextCloseable to AutoCloseable; please verify that all tests and callers are updated accordingly.
        override fun install(): AutoCloseable {

jvm/middleware/src/test/kotlin/io/spine/logging/jvm/context/ScopedLoggingContextSpec.kt:84

  • [nitpick] The method signature now accepts a non-nullable Tags parameter, aligning with the updated API; ensure that this change is intentional and that null checks elsewhere are adjusted accordingly.
    override fun addTags(tags: Tags): Boolean = false

contexts/std-context/src/main/kotlin/io/spine/logging/context/std/StdContextDataProvider.kt:105

  • The BuilderImpl.install() method has been modified to return AutoCloseable; confirm that the context restoration via CurrentStdContext.attach(previousData) properly maintains context state.
        override fun install(): AutoCloseable {

contexts/grpc-context/src/main/java/io/spine/logging/context/grpc/GrpcScopedLoggingContext.java:70

  • Returning AutoCloseable from install() instead of LoggingContextCloseable ensures consistency in context lifecycle handling; please verify that related logic (such as attach/detach) is functioning correctly.
      public AutoCloseable install() {

Copy link

codecov bot commented Jun 30, 2025

Codecov Report

Attention: Patch coverage is 43.26531% with 139 lines in your changes missing coverage. Please review.

Project coverage is 59.65%. Comparing base (3c6bc4c) to head (5cb9e75).

Additional details and impacted files
@@             Coverage Diff              @@
##             master     #104      +/-   ##
============================================
- Coverage     59.92%   59.65%   -0.28%     
+ Complexity      724      716       -8     
============================================
  Files           120      121       +1     
  Lines          3915     3916       +1     
  Branches        532      534       +2     
============================================
- Hits           2346     2336      -10     
- Misses         1361     1371      +10     
- Partials        208      209       +1     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@alexander-yevsyukov alexander-yevsyukov marked this pull request as draft July 2, 2025 08:43
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.

1 participant