Unverified Commit 44ece8e0 authored by Harry Barber's avatar Harry Barber Committed by GitHub
Browse files

Prevent build stalling with overlapping projections (#2602)

## Motivation and Context

Smithy CLI runs projections concurrently, for some currently unknown
reason this causes the build to stall.

## Description

- Switch `defaultRustMetadata` in `BaseSymbolMetadataProvider` from a
`val` to a `fun`.
- Remove unused `RustType::TestModule` companion object.

## Notes

A deadlock occurs when the client/server plugins both attempt to grab
file locks. While this fixes this deadlock it is unknown whether there
still exist conditions where it can happen.

## Testing

1. Checkout
https://github.com/crisidev/smithy-rs-pokemon-service/commit/d276bb95bbd7bf5c5f029953b8f16cecfa8af24f,
run `./gradlew assemble`, and observe the build halting.
2. Run the following commands to switch to this branch:
```bash
git submodule update --init --recursive --remote
cd smithy-rs
git checkout harryb/remove-build-deadlock
cd ..
./gradlew assemble
```
3. Observe the build succeeding.
parent 1a65a44e
Loading
Loading
Loading
Loading
+0 −9
Original line number Diff line number Diff line
@@ -422,15 +422,6 @@ data class RustMetadata(
    fun hasDebugDerive(): Boolean {
        return derives.contains(RuntimeType.Debug)
    }

    companion object {
        val TestModule = RustMetadata(
            visibility = Visibility.PRIVATE,
            additionalAttributes = listOf(
                Attribute.CfgTest,
            ),
        )
    }
}

data class Argument(val argument: String, val value: String, val type: String)
+6 −6
Original line number Diff line number Diff line
@@ -137,13 +137,13 @@ class BaseSymbolMetadataProvider(

    // Only the server subproject uses these, so we provide a sane and conservative default implementation here so that
    // the rest of symbol metadata providers can just delegate to it.
    private val defaultRustMetadata = RustMetadata(visibility = Visibility.PRIVATE)
    private fun defaultRustMetadata() = RustMetadata(visibility = Visibility.PRIVATE)

    override fun listMeta(listShape: ListShape) = defaultRustMetadata
    override fun mapMeta(mapShape: MapShape) = defaultRustMetadata
    override fun stringMeta(stringShape: StringShape) = defaultRustMetadata
    override fun numberMeta(numberShape: NumberShape) = defaultRustMetadata
    override fun blobMeta(blobShape: BlobShape) = defaultRustMetadata
    override fun listMeta(listShape: ListShape) = defaultRustMetadata()
    override fun mapMeta(mapShape: MapShape) = defaultRustMetadata()
    override fun stringMeta(stringShape: StringShape) = defaultRustMetadata()
    override fun numberMeta(numberShape: NumberShape) = defaultRustMetadata()
    override fun blobMeta(blobShape: BlobShape) = defaultRustMetadata()
}

private const val META_KEY = "meta"