jakarta-jmeter-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject cvs commit: jakarta-jmeter/src/protocol/tcp/org/apache/jmeter/protocol/tcp/sampler TCPSampler.java
Date Thu, 04 Aug 2005 23:48:08 GMT
sebb        2005/08/04 16:48:08

  Modified:    src/protocol/tcp/org/apache/jmeter/protocol/tcp/sampler
                        TCPSampler.java
  Log:
  Close socket if an error is encountered
  
  Revision  Changes    Path
  1.14      +15 -11    jakarta-jmeter/src/protocol/tcp/org/apache/jmeter/protocol/tcp/sampler/TCPSampler.java
  
  Index: TCPSampler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jmeter/src/protocol/tcp/org/apache/jmeter/protocol/tcp/sampler/TCPSampler.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- TCPSampler.java	4 Aug 2005 23:30:47 -0000	1.13
  +++ TCPSampler.java	4 Aug 2005 23:48:08 -0000	1.14
  @@ -294,22 +294,23 @@
   					}
   				}
   			}
  -		} catch (Exception ex) {
  +		} catch (IOException ex) {
   			log.debug("", ex);
   			res.setResponseCode("500");
   			res.setResponseMessage(ex.toString());
  -		}
  -
  -		// Calculate response time
  -		res.sampleEnd();
  -
  -		// Set if we were successful or not
  -		res.setSuccessful(isSuccessful);
  +            closeSocket();
  +		} finally {
  +    		// Calculate response time
  +    		res.sampleEnd();
  +    
  +    		// Set if we were successful or not
  +    		res.setSuccessful(isSuccessful);
  +        }
   
   		return res;
   	}
   
  -	/**
  +    /**
   	 * @param rc
   	 *            response code
   	 * @return whether this represents success or not
  @@ -328,8 +329,7 @@
           log.debug("Thread Started");
       }
   
  -    public void threadFinished() {
  -        log.debug("Thread Finished");
  +    private void closeSocket() {
           Map cp = (Map) tp.get();
           Socket con = (Socket) cp.remove(TCPKEY);
           if (con != null) {
  @@ -340,6 +340,10 @@
                   log.warn("Error closing socket "+e);
               }
           }
  +    }
   
  +    public void threadFinished() {
  +        log.debug("Thread Finished");
  +        closeSocket();
       }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org


Mime
View raw message