lib/jvertica.rb in jvertica-0.1.3 vs lib/jvertica.rb in jvertica-0.1.4

- old
+ new

@@ -1,6 +1,7 @@ require 'java' +require 'thread' require 'jvertica/version' require 'jdbc-vertica' require Jdbc::Vertica.driver_jar class Jvertica @@ -120,18 +121,21 @@ end elsif block_given? i, o = IO.pipe begin - yield(o) - o.close + thread = Thread.new do + yield(o) + o.close + end stream.addStream org.jruby.util.IOInputStream.new(i) rescue => e raise e ensure + thread.join end - end + rescue => e r = stream.finish raise e.class.new("[affected rows: #{r}] #{e.message}") end