diff --git a/crates/shim-protos/examples/ttrpc-server-async.rs b/crates/shim-protos/examples/ttrpc-server-async.rs index c6d373e0..1ae2020a 100644 --- a/crates/shim-protos/examples/ttrpc-server-async.rs +++ b/crates/shim-protos/examples/ttrpc-server-async.rs @@ -60,9 +60,7 @@ impl Task for FakeServer { async fn main() { simple_logger::SimpleLogger::new().init().unwrap(); - let t = Box::new(FakeServer::new()) as Box; - let t = Arc::new(t); - let tservice = create_task(t); + let tservice = create_task(Arc::new(FakeServer::new())); let mut server = Server::new() .bind("unix:///tmp/shim-proto-ttrpc-001") diff --git a/crates/shim-protos/examples/ttrpc-server.rs b/crates/shim-protos/examples/ttrpc-server.rs index 7c6c7360..f4f71891 100644 --- a/crates/shim-protos/examples/ttrpc-server.rs +++ b/crates/shim-protos/examples/ttrpc-server.rs @@ -57,9 +57,7 @@ impl Task for FakeServer { fn main() { simple_logger::SimpleLogger::new().init().unwrap(); - let t = Box::new(FakeServer::new()) as Box; - let t = Arc::new(t); - let tservice = create_task(t); + let tservice = create_task(Arc::new(FakeServer::new())); let mut server = Server::new() .bind("unix:///tmp/shim-proto-ttrpc-001") diff --git a/crates/shim-protos/tests/ttrpc.rs b/crates/shim-protos/tests/ttrpc.rs index 22c439ef..4d82321d 100644 --- a/crates/shim-protos/tests/ttrpc.rs +++ b/crates/shim-protos/tests/ttrpc.rs @@ -72,9 +72,7 @@ fn create_ttrpc_context() -> ( #[test] fn test_task_method_num() { - let server = Arc::new(Box::new(FakeServer::new()) as Box); - let task = create_task(server.clone()); - + let task = create_task(Arc::new(FakeServer::new())); assert_eq!(task.len(), 17); } @@ -98,8 +96,7 @@ fn test_create_task() { request.set_timeout_nano(10000); request.set_metadata(ttrpc::context::to_pb(ctx.metadata.clone())); - let server = Arc::new(Box::new(FakeServer::new()) as Box); - let task = create_task(server.clone()); + let task = create_task(Arc::new(FakeServer::new())); let create = task.get("/containerd.task.v2.Task/Create").unwrap(); create.handler(ctx, request).unwrap(); @@ -140,8 +137,7 @@ fn test_delete_task() { request.set_timeout_nano(10000); request.set_metadata(ttrpc::context::to_pb(ctx.metadata.clone())); - let server = Arc::new(Box::new(FakeServer::new()) as Box); - let task = create_task(server.clone()); + let task = create_task(Arc::new(FakeServer::new())); let delete = task.get("/containerd.task.v2.Task/Delete").unwrap(); delete.handler(ctx, request).unwrap(); diff --git a/crates/shim/src/asynchronous/mod.rs b/crates/shim/src/asynchronous/mod.rs index 4a145310..c43b729b 100644 --- a/crates/shim/src/asynchronous/mod.rs +++ b/crates/shim/src/asynchronous/mod.rs @@ -178,7 +178,7 @@ where let publisher = RemotePublisher::new(&ttrpc_address).await?; let task = shim.create_task_service(publisher).await; - let task_service = create_task(Arc::new(Box::new(task))); + let task_service = create_task(Arc::new(task)); let mut server = Server::new().register_service(task_service); server = server.add_listener(SOCKET_FD)?; server = server.set_domain_unix(); diff --git a/crates/shim/src/asynchronous/publisher.rs b/crates/shim/src/asynchronous/publisher.rs index 1c68f571..fac068ea 100644 --- a/crates/shim/src/asynchronous/publisher.rs +++ b/crates/shim/src/asynchronous/publisher.rs @@ -148,8 +148,7 @@ mod tests { let barrier2 = barrier.clone(); let server_thread = tokio::spawn(async move { let listener = UnixListener::bind(&path1).unwrap(); - let t = Arc::new(Box::new(server) as Box); - let service = create_events(t); + let service = create_events(Arc::new(server)); let mut server = Server::new() .set_domain_unix() .add_listener(listener.as_raw_fd()) diff --git a/crates/shim/src/synchronous/mod.rs b/crates/shim/src/synchronous/mod.rs index d1cfcc38..ced6a9a7 100644 --- a/crates/shim/src/synchronous/mod.rs +++ b/crates/shim/src/synchronous/mod.rs @@ -266,7 +266,7 @@ where let publisher = publisher::RemotePublisher::new(&ttrpc_address)?; let task = shim.create_task_service(publisher); - let task_service = create_task(Arc::new(Box::new(task))); + let task_service = create_task(Arc::new(task)); let mut server = create_server(flags)?; server = server.register_service(task_service); server.start()?; diff --git a/crates/shim/src/synchronous/publisher.rs b/crates/shim/src/synchronous/publisher.rs index 88c4f792..34d90482 100644 --- a/crates/shim/src/synchronous/publisher.rs +++ b/crates/shim/src/synchronous/publisher.rs @@ -188,8 +188,7 @@ mod tests { use std::os::unix::{io::AsRawFd, net::UnixListener}; let listener = UnixListener::bind(server_address).unwrap(); listener.set_nonblocking(true).unwrap(); - let t = Arc::new(Box::new(FakeServer {}) as Box); - let service = client::create_events(t); + let service = client::create_events(Arc::new(FakeServer {})); let server = Server::new() .add_listener(listener.as_raw_fd()) .unwrap()