Skip to content

Commit

Permalink
Fix the situation where the redis port is string. (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmjoy committed Jun 28, 2023
1 parent 0e4e02d commit 239eff9
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions src/plugin/plugin_redis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,18 +238,15 @@ impl RedisPlugin {
}
};
let port = {
let f = || {
execute_data
.get_parameter(1)
.as_long()
.context("isn't long")
};
match f() {
Ok(port) => port,
Err(err) => {
warn!(?err, "parse second argument to port failed, skipped.");
return Ok(Box::new(()));
}
let port = execute_data.get_parameter(1);

if let Some(port) = port.as_long() {
port.to_string()
} else if let Some(port) = port.as_z_str() {
port.to_str().unwrap_or("0").to_string()
} else {
warn!("parse second argument to port failed, skipped.");
return Ok(Box::new(()));
}
};

Expand Down

0 comments on commit 239eff9

Please sign in to comment.