Skip to content
This repository
Browse code

Update capability bugfix based on review feedback

Reduce scope of try/catch logic to only catch failures related to
the capabilities ETS table, therefore ensuring we do not silently
catch failures in other parts of the code.

Fix incorrect return value on failure: Ring => {false, Ring}
  • Loading branch information...
commit 41c9eb2f17462886069327f96b8ce4ac6367dc96 1 parent 4c3ed86
Joseph Blomstedt authored June 11, 2012

Showing 1 changed file with 12 additions and 6 deletions. Show diff stats Hide diff stats

  1. 18  src/riak_core_capability.erl
18  src/riak_core_capability.erl
@@ -165,12 +165,18 @@ update_ring(Ring) ->
165 165
     %% possible that the ETS table does not yet exist, or that the
166 166
     %% '$supported' key has not yet been written. Therefore, we catch
167 167
     %% any errors and return an unmodified ring.
168  
-    try
169  
-        [{_, Supported}] = ets:lookup(?ETS, '$supported'),
170  
-        add_supported_to_ring(node(), Supported, Ring)
171  
-    catch
172  
-        _:_ ->
173  
-            Ring
  168
+    Supported = try
  169
+                    [{_, Sup}] = ets:lookup(?ETS, '$supported'),
  170
+                    Sup
  171
+                catch
  172
+                    _:_ ->
  173
+                        error
  174
+                end,
  175
+    case Supported of
  176
+        error ->
  177
+            {false, Ring};
  178
+        _ ->
  179
+            add_supported_to_ring(node(), Supported, Ring)
174 180
     end.
175 181
 
176 182
 %% @doc Internal callback used by `riak_core_ring_handler' to notify the

0 notes on commit 41c9eb2

Please sign in to comment.
Something went wrong with that request. Please try again.