File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -51,11 +51,11 @@ def connect_with_retry
5151
5252        yield  http 
5353      rescue  *InfluxDB ::NON_RECOVERABLE_EXCEPTIONS  =>  e 
54-         http . finish 
54+         http . finish   if   http . started? 
5555
5656        raise  InfluxDB ::ConnectionError ,  InfluxDB ::NON_RECOVERABLE_MESSAGE 
5757      rescue  Timeout ::Error ,  *InfluxDB ::RECOVERABLE_EXCEPTIONS  =>  e 
58-         http . finish 
58+         http . finish   if   http . started? 
5959
6060        retry_count  += 1 
6161        unless  ( config . retry  == -1  || retry_count  <= config . retry )  && !stopped? 
Original file line number Diff line number Diff line change 3939    end 
4040  end 
4141
42+   describe  "#connect_with_retry"  do 
43+     it  "raises InfluxDB::ConnectionError when the hostname is unknown"  do 
44+       subject . config . retry  =  0 
45+ 
46+       allow_any_instance_of ( Net ::HTTP ) . to  receive ( :start )  do 
47+         raise  SocketError ,  "simulate getaddrinfo error" 
48+       end 
49+ 
50+       error  =  InfluxDB ::ConnectionError . new  "Tried 0 times to reconnect but failed." 
51+       expect  {  subject . send ( :connect_with_retry )  } . to  raise_error ( InfluxDB ::ConnectionError ) 
52+     end 
53+   end 
54+ 
4255  describe  "#full_url"  do 
4356    it  "returns String"  do 
4457      expect ( subject . send ( :full_url ,  "/unknown" ) ) . to  be_a  String 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments