Skip to content

Conversation

@lauzadis
Copy link
Member

@lauzadis lauzadis commented Aug 7, 2025

Issue #, if available:

Description of changes:
Address various issues raised during code review

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@lauzadis lauzadis requested a review from a team as a code owner August 7, 2025 14:18
@lauzadis lauzadis changed the title Add boundary checks to checksums V1877476818 kn: address misc issues Aug 7, 2025
@github-actions

This comment has been minimized.

@lauzadis lauzadis added the no-changelog Indicates that a changelog entry isn't required for a pull request. Use sparingly. label Aug 7, 2025
@github-actions

This comment has been minimized.

1 similar comment
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

1 similar comment
@github-actions

This comment has been minimized.

Comment on lines 228 to 236
val kShouldSignHeaderFn = userData.asStableRef<ShouldSignHeaderFunction>().get()
val kShouldSignHeaderStableRef = userData.asStableRef<ShouldSignHeaderFunction>()
val kShouldSignHeaderFn = kShouldSignHeaderStableRef.get()
val kHeaderName = headerName.pointed.toKString()
return kShouldSignHeaderFn(kHeaderName)
return kShouldSignHeaderFn(kHeaderName).also {
kShouldSignHeaderStableRef.dispose()
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: Is it important to dispose stable refs even when an exception occurs? If so, I think your use method may be appropriate here:

userData.asStableRef<ShouldSignHeaderFunction>().use { kShouldSignHeaderStableRef ->
    val kShouldSignHeaderFn = kShouldSignHeaderStableRef.get()
    val kHeaderName = headerName.pointed.toKString()
    return kShouldSignHeaderFn(kHeaderName)
}

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes it is, we should be disposing every StableRef created. I updated to use the use method

Comment on lines 109 to 111
} finally {
ctxStableRef.dispose()
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: Would it be better to use your use method here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes we should!

Comment on lines 94 to 98
pointer.pointed.buffer = if (dest.isNotEmpty()) {
pinned.addressOf(0).reinterpret()
} else {
null
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Style:

takeIf or takeUnless can clean this up a bit:

pointer.pointed.buffer =  pinned.takeUnless { dest.isEmpty() }?.addressOf(0)?.reinterpret()

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

1 similar comment
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

1 similar comment
@github-actions

This comment has been minimized.

@sonarqubecloud
Copy link

@github-actions
Copy link

Affected Artifacts

Changed in size
Artifact Pull Request (bytes) Latest Release (bytes) Delta (bytes) Delta (percentage)
aws-crt-kotlin-jvm.jar 221,683 216,897 4,786 2.21%

@lauzadis lauzadis merged commit e936caf into kn-main Aug 13, 2025
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog Indicates that a changelog entry isn't required for a pull request. Use sparingly.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants