Issue #234: Using builtin annotation classes before creating a CAS can break type system management#243
Conversation
…n break type system management - Try fixing the case if a JCCI was created with a bad type ID because the type ID had not been set yet
|
@reckart are we merging this fix, we are waiting for this fix to merge so that we can proceed with refactoring/442-Upgrade-to-UIMAv3 |
|
There is no fix yet - I need to find time to investigate it further because changes in this PR do not yet resolve the problem. The alternative would be a workaround. I think it might be sufficient to create a dummy CAS before the failing tests accesses the JCas classes. |
|
The work in this branch so far is unable to fix the problem. The recommended workaround is to create a CAS object before working with any JCas classes. |
Issue #235: Update dependencies
…before-creating-a-CAS-can-break-type-system-management * main: (1043 commits) Issue #444: Improve CasToComparableText No issue: Update rulesets Issue #444: Improve CasToComparableText No issue: Restore basic branch protections No issue: Temporarily disable all branch protections - hopefully then I can delete the `rel/441-Apache-UIMA-Java-SDK-3.6.1` branch [maven-release-plugin] prepare for next development iteration [maven-release-plugin] prepare release uimaj-3.6.1 No issue: Set branch in pom Issue #441: Apache UIMA Java SDK 3.6.1 Issue #441: Apache UIMA Java SDK 3.6.1 Issue #441: Apache UIMA Java SDK 3.6.1 Issue #438: Upgrade dependencies (3.6.1) No issue: Pull notifications up to root Issue #430: Resolving type system imports through sp is slows things down too much Issue #435: Improve performance of ImportResolver No issue: Try adding unit test report Issue #435: Improve performance of ImportResolver Issue #435: Improve performance of ImportResolver Issue #435: Improve performance of ImportResolver Issue #435: Improve performance of ImportResolver ...
…n break type system management - Revert bad fix - Add proper reproducer test
There was a problem hiding this comment.
Pull request overview
This PR addresses issue #234 where loading built-in JCas cover classes (notably Annotation) before any CAS exists can corrupt type system/JCas type-id bookkeeping and prevent feature callsite updates, leading to failures when later creating/using a CAS.
Changes:
- Adds a regression test that reproduces the problem in a fresh forked JVM and asserts the subprocess exits cleanly.
- Defers committing
TypeSystemImpl.staticTsifrom class initialization time to a new lazycommittedStaticTsi()accessor to avoid recursive class-init storms. - Updates
TypeSystemConstantsto obtain built-in feature adjusted offsets viaTypeSystemImpl.committedStaticTsi().
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
uimaj-core/src/test/java/org/apache/uima/jcas/impl/LoadingBuiltinAnnotationBeforeCasTest.java |
New regression test that forks a fresh JVM to reproduce/guard against issue #234. |
uimaj-core/src/main/java/org/apache/uima/cas/impl/TypeSystemImpl.java |
Switches static built-in type system commit to lazy-on-demand to prevent recursive initialization issues. |
uimaj-core/src/main/java/org/apache/uima/cas/impl/TypeSystemConstants.java |
Routes built-in feature adjusted-offset constants through the new lazy-commit accessor. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
4c5fa14 to
aa308af
Compare
…n break type system management - Defer `TypeSystemImpl.staticTsi.commit()` out of `<clinit>` into a new lazy `committedStaticTsi()` accessor with double-checked-locking on a volatile flag, breaking the recursive cover-class init storm that caused the issue - Route `TypeSystemConstants` builtin-feature `adjOffset` constants through `TypeSystemImpl.committedStaticTsi()` so they remain valid now that `staticTsi` is no longer committed eagerly
aa308af to
df242a5
Compare
…n break type system management - Drop dead `if (staticTsi == null)` guard in `TypeSystemImpl.createCallSiteForBuiltIn` and route the offset lookup through the cached `committedStaticTsi` field (read directly, not via the accessor, to avoid forcing a commit from inside a built-in cover class's `<clinit>` and reintroducing the issue-#234 init storm); fall through to a default callsite when no commit has happened yet - Replace OS-detection-based `java`/`java.exe` path construction in `LoadingBuiltinAnnotationBeforeCasTest` with `ProcessHandle.current().info().command()` plus a `${java.home}/bin/java` fallback (CreateProcess auto-resolves `.exe` on Windows) - Drain the forked JVM's output on a daemon thread so the 60s `waitFor` timeout actually fires when the subprocess deadlocks instead of being blocked indefinitely by a synchronous `transferTo`
What's in the PR
How to test manually
TimeMlAnnotateTestcaughAutomatic testing
Documentation
Organizational
Only dependencies under approved licenses are allowed. LICENSE and NOTICE files in the respective modules where dependencies have been added as well as in the project root have been updated.