Skip to content

Commit

Permalink
Suppress warnings about safe this leaks
Browse files Browse the repository at this point in the history
Leaking `this` before the constructor has completed can be dangerous in
general, specifically if any methods are called or not-yet-initialized
fields are used.  However, in the specific cases addressed here, the
escaping `this` is merely recorded in fields of other objects for later
use.  Members of `this` instance are not actually used during
construction, so these escapes are safe.
  • Loading branch information
liblit committed Sep 5, 2023
1 parent ab4e3e8 commit 1f962e6
Showing 1 changed file with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,13 @@ abstract class VerifiedDownload : DefaultTask() {

// plugin-provided extension for downloading a resource from some URL
@Internal
@Suppress("LeakingThis")
val downloadExtension: DownloadExtension =
project.objects.newInstance(DownloadExtension::class.java, this)

// plugin-provided extension for verifying that a file has the expected checksum
@Internal
@Suppress("LeakingThis")
val verifyExtension: VerifyExtension =
project.objects.newInstance(VerifyExtension::class.java, this)

Expand Down

0 comments on commit 1f962e6

Please sign in to comment.