Skip to content

Commit ee9eb7f

Browse files
committed
Fix observer handling
1 parent 1945c79 commit ee9eb7f

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

rust/src/hdfs/proxy.rs

+10-6
Original file line numberDiff line numberDiff line change
@@ -155,16 +155,20 @@ impl NameServiceProxy {
155155
// If we're writing, try the current known active and then loop
156156
// through the rest if that fails
157157
let first = current_active;
158-
let rest = (0..self.proxy_connections.len())
159-
.filter(|i| *i != first)
160-
.collect::<Vec<usize>>();
161-
[vec![first], rest].concat()
158+
let rest = (0..self.proxy_connections.len()).filter(|i| *i != first);
159+
[first].into_iter().chain(rest).collect::<Vec<_>>()
162160
} else {
163161
// If we're reading, try all known observers, then the active, then
164162
// any remaining
165-
let mut first = self.current_observers.lock().unwrap().clone();
163+
let mut first = self
164+
.current_observers
165+
.lock()
166+
.unwrap()
167+
.iter()
168+
.copied()
169+
.collect::<Vec<_>>();
166170
if !first.contains(&current_active) {
167-
first.insert(current_active);
171+
first.push(current_active);
168172
}
169173
let rest = (0..self.proxy_connections.len()).filter(|i| !first.contains(i));
170174
first.iter().copied().chain(rest).collect()

0 commit comments

Comments
 (0)