Skip to content

Don't cache fragment classes across different class loaders - #87

Closed
simonschiller wants to merge 2 commits into
androidx:androidx-master-devfrom
simonschiller:feature/separate-cache-per-class-loader
Closed

simonschiller wants to merge 2 commits into
androidx:androidx-master-devfrom
simonschiller:feature/separate-cache-per-class-loader

Conversation

@simonschiller

Copy link
Copy Markdown
Contributor

Proposed Changes

  • Don't cache fragment classes across different class loaders inside FragmentFactory.

Testing

Test: Added tests to verify the change

Issues Fixed

Fixes: 113886460

val classLoader = CountingClassLoader()
factory.instantiate(classLoader, TestFragment::class.java.name)
factory.instantiate(classLoader, TestFragment::class.java.name)
assertEquals(1, classLoader.loadCount)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please use Truth asserts (note, we already have a test dependency on Truth) over Junit asserts here and elsewhere in this file:

assertThat(classLoader.loadCount).isEqualTo(1)

Or preferably use the assertWithMessage() version that includes a more detailed message that is printed when the assert fails.

@ianhanniballake

Copy link
Copy Markdown
Member

Thanks for putting in this PR! It'll be available in the next Fragment release.

@simonschiller
simonschiller deleted the feature/separate-cache-per-class-loader branch January 22, 2021 06:57
harryzz pushed a commit to harryzz/compose-multiplatform-core that referenced this pull request Jul 28, 2026
## Proposed Changes

  - Don't cache fragment classes across different class loaders inside `FragmentFactory`.

## Testing

Test: Added tests to verify the change

## Issues Fixed

Fixes: 113886460

This is an imported pull request from androidx#87.

Resolves JetBrains#87
Github-Pr-Head-Sha: e5f5916
GitOrigin-RevId: babb5e1
Change-Id: I07d5541a45ccadcf7159854818000455e245d118
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants