[Groonga-commit] droonga/fluent-plugin-droonga at e6c0b02 [master] Handle error for missing queries

Back to archive index

YUKI Hiroshi null+****@clear*****
Thu Feb 6 19:41:47 JST 2014


YUKI Hiroshi	2014-02-06 19:41:47 +0900 (Thu, 06 Feb 2014)

  New Revision: e6c0b029429410102e3fdcea870419e2d672d81b
  https://github.com/droonga/fluent-plugin-droonga/commit/e6c0b029429410102e3fdcea870419e2d672d81b

  Message:
    Handle error for missing queries

  Modified files:
    lib/droonga/plugin/distributor/distributed_search_planner.rb
    lib/droonga/plugin/handler/search.rb
    test/unit/plugin/handler/test_search.rb

  Modified: lib/droonga/plugin/distributor/distributed_search_planner.rb (+2 -0)
===================================================================
--- lib/droonga/plugin/distributor/distributed_search_planner.rb    2014-02-06 19:37:13 +0900 (ec320ab)
+++ lib/droonga/plugin/distributor/distributed_search_planner.rb    2014-02-06 19:41:47 +0900 (355f9b9)
@@ -23,6 +23,8 @@ module Droonga
       super
 
       @request = @source_message["body"]
+      raise NoQuery.new unless @request
+
       @request = Marshal.load(Marshal.dump(@request))
       @queries = @request["queries"]
     end

  Modified: lib/droonga/plugin/handler/search.rb (+3 -1)
===================================================================
--- lib/droonga/plugin/handler/search.rb    2014-02-06 19:37:13 +0900 (0e33cc5)
+++ lib/droonga/plugin/handler/search.rb    2014-02-06 19:41:47 +0900 (f7468de)
@@ -26,7 +26,9 @@ module Droonga
     def search(message, messenger)
       searcher = Droonga::Searcher.new(@context)
       values = {}
-      searcher.search(message.request["queries"]).each do |output, value|
+      request = message.request
+      raise Droonga::Searcher::NoQuery.new unless request
+      searcher.search(request["queries"]).each do |output, value|
         values[output] = value
       end
       messenger.emit(values)

  Modified: test/unit/plugin/handler/test_search.rb (+12 -0)
===================================================================
--- test/unit/plugin/handler/test_search.rb    2014-02-06 19:37:13 +0900 (393d504)
+++ test/unit/plugin/handler/test_search.rb    2014-02-06 19:41:47 +0900 (abe3502)
@@ -82,6 +82,12 @@ class SearchHandlerTest < Test::Unit::TestCase
           search({})
         end
       end
+
+      def test_nil
+        assert_raise(Droonga::Searcher::NoQuery) do
+          search(nil)
+        end
+      end
     end
 
     class QueriesTest < self
@@ -90,6 +96,12 @@ class SearchHandlerTest < Test::Unit::TestCase
           search({"queries" => {}})
         end
       end
+
+      def test_nil
+        assert_raise(Droonga::Searcher::NoQuery) do
+          search({"queries" => nil})
+        end
+      end
     end
 
     class HashQueryTest < self
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index