fix: replace unwrap() with expect() in more files (#729 batch 13) (#3993)

This commit is contained in:
Zhengchao An
2026-06-28 11:45:13 +08:00
committed by GitHub
parent f0ab812213
commit 05d201679c
15 changed files with 126 additions and 126 deletions
+27 -27
View File
@@ -246,7 +246,7 @@ impl Operation for CreateKeyHandler {
.map_err(|e| s3_error!(InternalError, "failed to serialize response: {}", e))?;
let mut headers = HeaderMap::new();
headers.insert(CONTENT_TYPE, "application/json".parse().unwrap());
headers.insert(CONTENT_TYPE, "application/json".parse().expect("operation should succeed"));
Ok(S3Response::with_headers((StatusCode::OK, Body::from(data)), headers))
}
@@ -309,7 +309,7 @@ impl Operation for DescribeKeyHandler {
.map_err(|e| s3_error!(InternalError, "failed to serialize response: {}", e))?;
let mut headers = HeaderMap::new();
headers.insert(CONTENT_TYPE, "application/json".parse().unwrap());
headers.insert(CONTENT_TYPE, "application/json".parse().expect("operation should succeed"));
Ok(S3Response::with_headers((StatusCode::OK, Body::from(data)), headers))
}
@@ -474,7 +474,7 @@ impl Operation for ListKeysHandler {
.map_err(|e| s3_error!(InternalError, "failed to serialize response: {}", e))?;
let mut headers = HeaderMap::new();
headers.insert(CONTENT_TYPE, "application/json".parse().unwrap());
headers.insert(CONTENT_TYPE, "application/json".parse().expect("operation should succeed"));
Ok(S3Response::with_headers((StatusCode::OK, Body::from(data)), headers))
}
@@ -548,7 +548,7 @@ impl Operation for GenerateDataKeyHandler {
.map_err(|e| s3_error!(InternalError, "failed to serialize response: {}", e))?;
let mut headers = HeaderMap::new();
headers.insert(CONTENT_TYPE, "application/json".parse().unwrap());
headers.insert(CONTENT_TYPE, "application/json".parse().expect("operation should succeed"));
Ok(S3Response::with_headers((StatusCode::OK, Body::from(data)), headers))
}
@@ -617,7 +617,7 @@ impl Operation for CreateKmsKeyHandler {
let data =
serde_json::to_vec(&response).map_err(|e| s3_error!(InternalError, "failed to serialize response: {}", e))?;
let mut headers = HeaderMap::new();
headers.insert(CONTENT_TYPE, "application/json".parse().unwrap());
headers.insert(CONTENT_TYPE, "application/json".parse().expect("operation should succeed"));
return Ok(S3Response::with_headers((StatusCode::SERVICE_UNAVAILABLE, Body::from(data)), headers));
};
@@ -631,7 +631,7 @@ impl Operation for CreateKmsKeyHandler {
let data =
serde_json::to_vec(&response).map_err(|e| s3_error!(InternalError, "failed to serialize response: {}", e))?;
let mut headers = HeaderMap::new();
headers.insert(CONTENT_TYPE, "application/json".parse().unwrap());
headers.insert(CONTENT_TYPE, "application/json".parse().expect("operation should succeed"));
return Ok(S3Response::with_headers((StatusCode::SERVICE_UNAVAILABLE, Body::from(data)), headers));
};
@@ -670,7 +670,7 @@ impl Operation for CreateKmsKeyHandler {
serde_json::to_vec(&response).map_err(|e| s3_error!(InternalError, "failed to serialize response: {}", e))?;
let mut headers = HeaderMap::new();
headers.insert(CONTENT_TYPE, "application/json".parse().unwrap());
headers.insert(CONTENT_TYPE, "application/json".parse().expect("operation should succeed"));
Ok(S3Response::with_headers((StatusCode::OK, Body::from(data)), headers))
}
@@ -695,7 +695,7 @@ impl Operation for CreateKmsKeyHandler {
serde_json::to_vec(&response).map_err(|e| s3_error!(InternalError, "failed to serialize response: {}", e))?;
let mut headers = HeaderMap::new();
headers.insert(CONTENT_TYPE, "application/json".parse().unwrap());
headers.insert(CONTENT_TYPE, "application/json".parse().expect("operation should succeed"));
Ok(S3Response::with_headers((StatusCode::INTERNAL_SERVER_ERROR, Body::from(data)), headers))
}
@@ -760,7 +760,7 @@ impl Operation for DeleteKmsKeyHandler {
let data =
serde_json::to_vec(&response).map_err(|e| s3_error!(InternalError, "failed to serialize response: {}", e))?;
let mut headers = HeaderMap::new();
headers.insert(CONTENT_TYPE, "application/json".parse().unwrap());
headers.insert(CONTENT_TYPE, "application/json".parse().expect("operation should succeed"));
return Ok(S3Response::with_headers((StatusCode::BAD_REQUEST, Body::from(data)), headers));
};
@@ -787,7 +787,7 @@ impl Operation for DeleteKmsKeyHandler {
let data =
serde_json::to_vec(&response).map_err(|e| s3_error!(InternalError, "failed to serialize response: {}", e))?;
let mut headers = HeaderMap::new();
headers.insert(CONTENT_TYPE, "application/json".parse().unwrap());
headers.insert(CONTENT_TYPE, "application/json".parse().expect("operation should succeed"));
return Ok(S3Response::with_headers((StatusCode::SERVICE_UNAVAILABLE, Body::from(data)), headers));
};
@@ -801,7 +801,7 @@ impl Operation for DeleteKmsKeyHandler {
let data =
serde_json::to_vec(&response).map_err(|e| s3_error!(InternalError, "failed to serialize response: {}", e))?;
let mut headers = HeaderMap::new();
headers.insert(CONTENT_TYPE, "application/json".parse().unwrap());
headers.insert(CONTENT_TYPE, "application/json".parse().expect("operation should succeed"));
return Ok(S3Response::with_headers((StatusCode::SERVICE_UNAVAILABLE, Body::from(data)), headers));
};
@@ -833,7 +833,7 @@ impl Operation for DeleteKmsKeyHandler {
serde_json::to_vec(&response).map_err(|e| s3_error!(InternalError, "failed to serialize response: {}", e))?;
let mut headers = HeaderMap::new();
headers.insert(CONTENT_TYPE, "application/json".parse().unwrap());
headers.insert(CONTENT_TYPE, "application/json".parse().expect("operation should succeed"));
Ok(S3Response::with_headers((StatusCode::OK, Body::from(data)), headers))
}
@@ -864,7 +864,7 @@ impl Operation for DeleteKmsKeyHandler {
serde_json::to_vec(&response).map_err(|e| s3_error!(InternalError, "failed to serialize response: {}", e))?;
let mut headers = HeaderMap::new();
headers.insert(CONTENT_TYPE, "application/json".parse().unwrap());
headers.insert(CONTENT_TYPE, "application/json".parse().expect("operation should succeed"));
Ok(S3Response::with_headers((status, Body::from(data)), headers))
}
@@ -927,7 +927,7 @@ impl Operation for CancelKmsKeyDeletionHandler {
let data =
serde_json::to_vec(&response).map_err(|e| s3_error!(InternalError, "failed to serialize response: {}", e))?;
let mut headers = HeaderMap::new();
headers.insert(CONTENT_TYPE, "application/json".parse().unwrap());
headers.insert(CONTENT_TYPE, "application/json".parse().expect("operation should succeed"));
return Ok(S3Response::with_headers((StatusCode::BAD_REQUEST, Body::from(data)), headers));
};
CancelKmsKeyDeletionRequest { key_id: key_id.clone() }
@@ -945,7 +945,7 @@ impl Operation for CancelKmsKeyDeletionHandler {
let data =
serde_json::to_vec(&response).map_err(|e| s3_error!(InternalError, "failed to serialize response: {}", e))?;
let mut headers = HeaderMap::new();
headers.insert(CONTENT_TYPE, "application/json".parse().unwrap());
headers.insert(CONTENT_TYPE, "application/json".parse().expect("operation should succeed"));
return Ok(S3Response::with_headers((StatusCode::SERVICE_UNAVAILABLE, Body::from(data)), headers));
};
@@ -959,7 +959,7 @@ impl Operation for CancelKmsKeyDeletionHandler {
let data =
serde_json::to_vec(&response).map_err(|e| s3_error!(InternalError, "failed to serialize response: {}", e))?;
let mut headers = HeaderMap::new();
headers.insert(CONTENT_TYPE, "application/json".parse().unwrap());
headers.insert(CONTENT_TYPE, "application/json".parse().expect("operation should succeed"));
return Ok(S3Response::with_headers((StatusCode::SERVICE_UNAVAILABLE, Body::from(data)), headers));
};
@@ -989,7 +989,7 @@ impl Operation for CancelKmsKeyDeletionHandler {
serde_json::to_vec(&response).map_err(|e| s3_error!(InternalError, "failed to serialize response: {}", e))?;
let mut headers = HeaderMap::new();
headers.insert(CONTENT_TYPE, "application/json".parse().unwrap());
headers.insert(CONTENT_TYPE, "application/json".parse().expect("operation should succeed"));
Ok(S3Response::with_headers((StatusCode::OK, Body::from(data)), headers))
}
@@ -1015,7 +1015,7 @@ impl Operation for CancelKmsKeyDeletionHandler {
serde_json::to_vec(&response).map_err(|e| s3_error!(InternalError, "failed to serialize response: {}", e))?;
let mut headers = HeaderMap::new();
headers.insert(CONTENT_TYPE, "application/json".parse().unwrap());
headers.insert(CONTENT_TYPE, "application/json".parse().expect("operation should succeed"));
Ok(S3Response::with_headers((StatusCode::INTERNAL_SERVER_ERROR, Body::from(data)), headers))
}
@@ -1070,7 +1070,7 @@ impl Operation for ListKmsKeysHandler {
let data =
serde_json::to_vec(&response).map_err(|e| s3_error!(InternalError, "failed to serialize response: {}", e))?;
let mut headers = HeaderMap::new();
headers.insert(CONTENT_TYPE, "application/json".parse().unwrap());
headers.insert(CONTENT_TYPE, "application/json".parse().expect("operation should succeed"));
return Ok(S3Response::with_headers((StatusCode::SERVICE_UNAVAILABLE, Body::from(data)), headers));
};
@@ -1085,7 +1085,7 @@ impl Operation for ListKmsKeysHandler {
let data =
serde_json::to_vec(&response).map_err(|e| s3_error!(InternalError, "failed to serialize response: {}", e))?;
let mut headers = HeaderMap::new();
headers.insert(CONTENT_TYPE, "application/json".parse().unwrap());
headers.insert(CONTENT_TYPE, "application/json".parse().expect("operation should succeed"));
return Ok(S3Response::with_headers((StatusCode::SERVICE_UNAVAILABLE, Body::from(data)), headers));
};
@@ -1119,7 +1119,7 @@ impl Operation for ListKmsKeysHandler {
serde_json::to_vec(&response).map_err(|e| s3_error!(InternalError, "failed to serialize response: {}", e))?;
let mut headers = HeaderMap::new();
headers.insert(CONTENT_TYPE, "application/json".parse().unwrap());
headers.insert(CONTENT_TYPE, "application/json".parse().expect("operation should succeed"));
Ok(S3Response::with_headers((StatusCode::OK, Body::from(data)), headers))
}
@@ -1145,7 +1145,7 @@ impl Operation for ListKmsKeysHandler {
serde_json::to_vec(&response).map_err(|e| s3_error!(InternalError, "failed to serialize response: {}", e))?;
let mut headers = HeaderMap::new();
headers.insert(CONTENT_TYPE, "application/json".parse().unwrap());
headers.insert(CONTENT_TYPE, "application/json".parse().expect("operation should succeed"));
Ok(S3Response::with_headers((StatusCode::INTERNAL_SERVER_ERROR, Body::from(data)), headers))
}
@@ -1192,7 +1192,7 @@ impl Operation for DescribeKmsKeyHandler {
let data =
serde_json::to_vec(&response).map_err(|e| s3_error!(InternalError, "failed to serialize response: {}", e))?;
let mut headers = HeaderMap::new();
headers.insert(CONTENT_TYPE, "application/json".parse().unwrap());
headers.insert(CONTENT_TYPE, "application/json".parse().expect("operation should succeed"));
return Ok(S3Response::with_headers((StatusCode::BAD_REQUEST, Body::from(data)), headers));
};
@@ -1205,7 +1205,7 @@ impl Operation for DescribeKmsKeyHandler {
let data =
serde_json::to_vec(&response).map_err(|e| s3_error!(InternalError, "failed to serialize response: {}", e))?;
let mut headers = HeaderMap::new();
headers.insert(CONTENT_TYPE, "application/json".parse().unwrap());
headers.insert(CONTENT_TYPE, "application/json".parse().expect("operation should succeed"));
return Ok(S3Response::with_headers((StatusCode::SERVICE_UNAVAILABLE, Body::from(data)), headers));
};
@@ -1218,7 +1218,7 @@ impl Operation for DescribeKmsKeyHandler {
let data =
serde_json::to_vec(&response).map_err(|e| s3_error!(InternalError, "failed to serialize response: {}", e))?;
let mut headers = HeaderMap::new();
headers.insert(CONTENT_TYPE, "application/json".parse().unwrap());
headers.insert(CONTENT_TYPE, "application/json".parse().expect("operation should succeed"));
return Ok(S3Response::with_headers((StatusCode::SERVICE_UNAVAILABLE, Body::from(data)), headers));
};
@@ -1247,7 +1247,7 @@ impl Operation for DescribeKmsKeyHandler {
serde_json::to_vec(&response).map_err(|e| s3_error!(InternalError, "failed to serialize response: {}", e))?;
let mut headers = HeaderMap::new();
headers.insert(CONTENT_TYPE, "application/json".parse().unwrap());
headers.insert(CONTENT_TYPE, "application/json".parse().expect("operation should succeed"));
Ok(S3Response::with_headers((StatusCode::OK, Body::from(data)), headers))
}
@@ -1278,7 +1278,7 @@ impl Operation for DescribeKmsKeyHandler {
serde_json::to_vec(&response).map_err(|e| s3_error!(InternalError, "failed to serialize response: {}", e))?;
let mut headers = HeaderMap::new();
headers.insert(CONTENT_TYPE, "application/json".parse().unwrap());
headers.insert(CONTENT_TYPE, "application/json".parse().expect("operation should succeed"));
Ok(S3Response::with_headers((status, Body::from(data)), headers))
}
+2 -2
View File
@@ -70,7 +70,7 @@ impl Operation for TriggerProfileCPU {
match crate::profiling::dump_cpu_pprof_for(dur).await {
Ok(path) => {
let mut header = HeaderMap::new();
header.insert(CONTENT_TYPE, "text/html".parse().unwrap());
header.insert(CONTENT_TYPE, "text/html".parse().expect("operation should succeed"));
Ok(S3Response::with_headers((StatusCode::OK, Body::from(path.display().to_string())), header))
}
Err(e) => Err(s3s::s3_error!(InternalError, "{}", format!("Failed to dump CPU profile: {e}"))),
@@ -99,7 +99,7 @@ impl Operation for TriggerProfileMemory {
match crate::profiling::dump_memory_pprof_now().await {
Ok(path) => {
let mut header = HeaderMap::new();
header.insert(CONTENT_TYPE, "text/html".parse().unwrap());
header.insert(CONTENT_TYPE, "text/html".parse().expect("operation should succeed"));
Ok(S3Response::with_headers((StatusCode::OK, Body::from(path.display().to_string())), header))
}
Err(e) => Err(s3s::s3_error!(InternalError, "{}", format!("Failed to dump Memory profile: {e}"))),
+2 -2
View File
@@ -1995,7 +1995,7 @@ async fn put_replication_probe_object(
.customize()
.map_request(move |mut req| {
for (key, value) in headers.clone() {
req.headers_mut().insert(key.unwrap(), value);
req.headers_mut().insert(key.expect("operation should succeed"), value);
}
Result::<_, std::io::Error>::Ok(req)
})
@@ -2039,7 +2039,7 @@ async fn delete_replication_probe_object(
.customize()
.map_request(move |mut req| {
for (key, value) in headers.clone() {
req.headers_mut().insert(key.unwrap(), value);
req.headers_mut().insert(key.expect("operation should succeed"), value);
}
Result::<_, std::io::Error>::Ok(req)
})
+1 -1
View File
@@ -89,7 +89,7 @@ fn compute_default_max_blocking_threads() -> usize {
/// ```no_run
/// // tokio_runtime_builder is pub(crate) - call it from within the rustfs binary:
/// // let builder = tokio_runtime_builder();
/// // let runtime = builder.build().unwrap();
/// // let runtime = builder.build().expect("operation should succeed");
/// ```
pub fn tokio_runtime_builder() -> tokio::runtime::Builder {
let mut builder = tokio::runtime::Builder::new_multi_thread();