nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: tower-rs/tower
Pull request #581 (2021-04-26 23:58:53)

spawn-ready: Abort background tasks when the service is dropped
The `SpawnReady` service spawns a background task whenever the inner
service is not ready; but when the `SpawnReady` service is dropped, this
task continues to run until it becomes ready (at which point the ready
service will be dropped). This can cause resource leaks when the inner
service never becomes ready.

This change adds a `Drop` implementation for the `SpawnReady` service
that aborts the background task when appropriate.


Patch:
diff --git a/tower/src/spawn_ready/service.rs b/tower/src/spawn_ready/service.rs
index e9a3b93..3b2af5d 100644
--- a/tower/src/spawn_ready/service.rs
+++ b/tower/src/spawn_ready/service.rs
@@ -33,6 +33,14 @@ impl<S> SpawnReady<S> {
     }
 }
 
+impl<S> Drop for SpawnReady<S> {
+    fn drop(&mut self) {
+        if let Inner::Future(ref mut task) = self.inner {
+            task.abort();
+        }
+    }
+}
+
 impl<S, Req> Service<Req> for SpawnReady<S>
 where
     Req: 'static,


Test patch:
diff --git a/tower/tests/spawn_ready/main.rs b/tower/tests/spawn_ready/main.rs
index d6f9e8c..be19d12 100644
--- a/tower/tests/spawn_ready/main.rs
+++ b/tower/tests/spawn_ready/main.rs
@@ -5,6 +5,7 @@ mod support;
 use tokio::time;
 use tokio_test::{assert_pending, assert_ready, assert_ready_err, assert_ready_ok};
 use tower::spawn_ready::{SpawnReady, SpawnReadyLayer};
+use tower::util::ServiceExt;
 use tower_test::mock;
 
 #[tokio::test(flavor = "current_thread")]
@@ -46,7 +47,6 @@ async fn when_inner_fails() {
 
 #[tokio::test(flavor = "current_thread")]
 async fn propagates_trace_spans() {
-    use tower::util::ServiceExt;
     use tracing::Instrument;
 
     let _t = support::trace_init();
@@ -59,3 +59,27 @@ async fn propagates_trace_spans() {
 
     result.await.expect("service panicked").expect("failed");
 }
+
+#[cfg(test)]
+#[tokio::test(flavor = "current_thread")]
+async fn abort_on_drop() {
+    let (mock, mut handle) = mock::pair::<(), ()>();
+    let mut svc = SpawnReady::new(mock);
+    handle.allow(0);
+
+    // Drive the service to readiness until we signal a drop.
+    let (drop_tx, drop_rx) = tokio::sync::oneshot::channel();
+    let mut task = tokio_test::task::spawn(async move {
+        tokio::select! {
+            _ = drop_rx => {}
+            _ = svc.ready() => unreachable!("Service must not become ready"),
+        }
+    });
+    assert_pending!(task.poll());
+    assert_pending!(handle.poll_request());
+
+    // End the task and ensure that the inner service has been dropped.
+    assert!(drop_tx.send(()).is_ok());
+    tokio_test::assert_ready!(task.poll());
+    assert!(tokio_test::assert_ready!(handle.poll_request()).is_none());
+}
Repository: tower-rs/tower
Pull request #620 (2021-11-19 03:13:42)

tower: update hdrhistogram to 7.0 and remove useless dependencies
Signed-off-by: koushiro <koushiro.cqx@gmail.com>

* update `hdrhistogram` to 7.0
* remove useless dependency 'quickcheck'
* add `path` for `tower-service` dependency.


Patch:
diff --git a/tower/Cargo.toml b/tower/Cargo.toml
index 237becf..6b3d9b8 100644
--- a/tower/Cargo.toml
+++ b/tower/Cargo.toml
@@ -65,10 +65,10 @@ util = ["futures-util"]
 futures-core = "0.3"
 pin-project = "1"
 tower-layer = { version = "0.3.1", path = "../tower-layer" }
-tower-service = { version = "0.3" }
+tower-service = { version = "0.3.1", path = "../tower-service" }
 
 futures-util = { version = "0.3", default-features = false, features = ["alloc"], optional = true }
-hdrhistogram = { version = "6.0", optional = true }
+hdrhistogram = { version = "7.0", optional = true }
 indexmap = { version = "1.0.2", optional = true }
 rand = { version = "0.8", features = ["small_rng"], optional = true }
 slab = { version = "0.4", optional = true }
@@ -80,8 +80,7 @@ pin-project-lite = "0.2.7"
 
 [dev-dependencies]
 futures = "0.3"
-hdrhistogram = "6.0"
-quickcheck = { version = "0.9", default-features = false }
+hdrhistogram = "7.0"
 tokio = { version = "1", features = ["macros", "sync", "test-util", "rt-multi-thread"] }
 tokio-stream = "0.1"
 tokio-test = "0.4"


Test patch:
diff --git a/tower-test/Cargo.toml b/tower-test/Cargo.toml
index 4a2749f..9d57672 100644
--- a/tower-test/Cargo.toml
+++ b/tower-test/Cargo.toml
@@ -26,7 +26,7 @@ futures-util = { version = "0.3", default-features = false }
 tokio = { version = "1.0", features = ["sync"] }
 tokio-test = "0.4"
 tower-layer = { version = "0.3", path = "../tower-layer" }
-tower-service = { version = "0.3" }
+tower-service = { version = "0.3", path = "../tower-service" }
 pin-project-lite = "0.2"
 
 [dev-dependencies]
Repository: tower-rs/tower
Pull request #747 (2023-10-08 06:18:41)

docs:Fix some spelling mistakes
- Fix some spelling mistakes


Patch:
diff --git a/tower/src/retry/backoff.rs b/tower/src/retry/backoff.rs
index 306723e..685063e 100644
--- a/tower/src/retry/backoff.rs
+++ b/tower/src/retry/backoff.rs
@@ -1,4 +1,4 @@
-//! This module contains generic [backoff] utlities to be used with the retry
+//! This module contains generic [backoff] utilities to be used with the retry
 //! layer.
 //!
 //! The [`Backoff`] trait is a generic way to represent backoffs that can use
diff --git a/tower/src/retry/budget/tps_budget.rs b/tower/src/retry/budget/tps_budget.rs
index 3f1d530..d694998 100644
--- a/tower/src/retry/budget/tps_budget.rs
+++ b/tower/src/retry/budget/tps_budget.rs
@@ -31,7 +31,7 @@ pub struct TpsBudget {
     slots: Box<[AtomicIsize]>,
     /// The amount of time represented by each slot.
     window: Duration,
-    /// The changers for the current slot to be commited
+    /// The changers for the current slot to be committed
     /// after the slot expires.
     writer: AtomicIsize,
     /// Amount of tokens to deposit for each put().
diff --git a/tower/src/util/rng.rs b/tower/src/util/rng.rs
index d520ffc..cf5932d 100644
--- a/tower/src/util/rng.rs
+++ b/tower/src/util/rng.rs
@@ -3,7 +3,7 @@
 //! This module provides a generic [`Rng`] trait and a [`HasherRng`] that
 //! implements the trait based on [`RandomState`] or any other [`Hasher`].
 //!
-//! These utlities replace tower's internal usage of `rand` with these smaller,
+//! These utilities replace tower's internal usage of `rand` with these smaller,
 //! more lightweight methods. Most of the implementations are extracted from
 //! their corresponding `rand` implementations.
 //!
@@ -111,7 +111,7 @@ where
 
 /// A sampler modified from the Rand implementation for use internally for the balance middleware.
 ///
-/// It's an implemenetation of Floyd's combination algorithm. with amount fixed at 2. This uses no allocated
+/// It's an implementation of Floyd's combination algorithm. with amount fixed at 2. This uses no allocated
 /// memory and finishes in constant time (only 2 random calls)
 ///
 /// ref: This was borrowed and modified from the following Rand implementation


Test patch:
diff --git a/tower/tests/ready_cache/main.rs b/tower/tests/ready_cache/main.rs
index 56be6a9..cdcfcbb 100644
--- a/tower/tests/ready_cache/main.rs
+++ b/tower/tests/ready_cache/main.rs
@@ -200,7 +200,7 @@ async fn cancelation_observed() {
     let mut handles = vec![];
 
     // NOTE This test passes at 129 items, but fails at 130 items (if coop
-    // schedulding interferes with cancelation).
+    // scheduling interferes with cancelation).
     for _ in 0..130 {
         let (svc, mut handle) = tower_test::mock::pair::<(), ()>();
         handle.allow(1);
Repository: tower-rs/tower
Pull request #441 (2020-04-17 16:44:17)

Remove path deps for `tower-service`
This is causing issues where depending from git will pull in the git version of tower-service while locally I want it to match with the crates version. I think this is fine in general because we do not plan to make any changes to `tower-service` before a `0.4` release.


Patch:
diff --git a/deny.toml b/deny.toml
index 3284e5e..4f0a839 100644
--- a/deny.toml
+++ b/deny.toml
@@ -15,6 +15,9 @@ confidence-threshold = 0.8
 [bans]
 multiple-versions = "deny"
 highlight = "all"
+skip-tree = [
+    { name = "tower", version = "=0.3"}
+]
 
 [sources]
 unknown-registry = "warn"
diff --git a/tower-layer/Cargo.toml b/tower-layer/Cargo.toml
index f3b050f..5e6d687 100644
--- a/tower-layer/Cargo.toml
+++ b/tower-layer/Cargo.toml
@@ -24,4 +24,4 @@ edition = "2018"
 [dependencies]
 
 [dev-dependencies]
-tower-service = { version = "0.3.0", path = "../tower-service" }
+tower-service = { version = "0.3.0" }
diff --git a/tower/Cargo.toml b/tower/Cargo.toml
index e15f02e..f15eb14 100644
--- a/tower/Cargo.toml
+++ b/tower/Cargo.toml
@@ -47,7 +47,7 @@ util = ["futures-util"]
 futures-core = "0.3"
 pin-project = "0.4"
 tower-layer = { version = "0.3", path = "../tower-layer" }
-tower-service = { version = "0.3", path = "../tower-service" }
+tower-service = { version = "0.3" }
 tracing = "0.1.2"
 
 futures-util = { version = "0.3", default-features = false, features = ["alloc"], optional = true }


Test patch:
diff --git a/tower-test/Cargo.toml b/tower-test/Cargo.toml
index 18412a5..a854495 100644
--- a/tower-test/Cargo.toml
+++ b/tower-test/Cargo.toml
@@ -26,7 +26,7 @@ futures-util = { version = "0.3", default-features = false }
 tokio = { version = "0.2", features = ["sync"]}
 tower-layer = { version = "0.3", path = "../tower-layer" }
 tokio-test = "0.2"
-tower-service = { version = "0.3", path = "../tower-service" }
+tower-service = { version = "0.3" }
 pin-project = "0.4"
 
 [dev-dependencies]