jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1781814 - in /jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc: AbstractJDBCTestElement.java config/DataSourceElement.java config/DataSourceElementBeanInfo.java processor/AbstractJDBCProcessor.java sampler/JDBCSampler.java
Date Sun, 05 Feb 2017 21:51:30 GMT
Author: pmouawad
Date: Sun Feb  5 21:51:30 2017
New Revision: 1781814

URL: http://svn.apache.org/viewvc?rev=1781814&view=rev
Log:
Bug 60564 - Migrating LogKit to SLF4J - Replace logkit loggers with slf4j ones with keeping
the current logkit binding solution
Use slf4j parameterized messages
Bugzilla Id: 60564

Modified:
    jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/AbstractJDBCTestElement.java
    jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/config/DataSourceElement.java
    jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/config/DataSourceElementBeanInfo.java
    jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/processor/AbstractJDBCProcessor.java
    jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/sampler/JDBCSampler.java

Modified: jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/AbstractJDBCTestElement.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/AbstractJDBCTestElement.java?rev=1781814&r1=1781813&r2=1781814&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/AbstractJDBCTestElement.java
(original)
+++ jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/AbstractJDBCTestElement.java
Sun Feb  5 21:51:30 2017
@@ -50,8 +50,8 @@ import org.apache.jmeter.testelement.Abs
 import org.apache.jmeter.testelement.TestStateListener;
 import org.apache.jmeter.threads.JMeterVariables;
 import org.apache.jmeter.util.JMeterUtils;
-import org.apache.jorphan.logging.LoggingManager;
-import org.apache.log.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * A base class for all JDBC test elements handling the basics of a SQL request.
@@ -60,7 +60,7 @@ import org.apache.log.Logger;
 public abstract class AbstractJDBCTestElement extends AbstractTestElement implements TestStateListener{
     private static final long serialVersionUID = 235L;
 
-    private static final Logger log = LoggingManager.getLoggerForClass();
+    private static final Logger log = LoggerFactory.getLogger(AbstractJDBCTestElement.class);
 
     private static final String COMMA = ","; // $NON-NLS-1$
     private static final char COMMA_CHAR = ',';
@@ -161,7 +161,7 @@ public abstract class AbstractJDBCTestEl
      * @throws UnsupportedOperationException if the user provided incorrect query type
      */
     protected byte[] execute(Connection conn, SampleResult sample) throws SQLException, IOException,
UnsupportedOperationException {
-        log.debug("executing jdbc");
+        log.debug("executing jdbc:{}", getQuery());
         // Based on query return value, get results
         String _queryType = getQueryType();
         if (SELECT.equals(_queryType)) {
@@ -329,7 +329,7 @@ public abstract class AbstractJDBCTestEl
                 }
             }
         } catch (IOException e) {
-            log.warn("Could not read CLOB into " + name, e);
+            log.warn("Could not read CLOB into {}", name, e);
         }
     }
 
@@ -341,7 +341,7 @@ public abstract class AbstractJDBCTestEl
                 jmvars.putObject(name,
                         IOUtils.toByteArray(blob.getBinaryStream(0, length)));
             } catch (IOException e) {
-                log.warn("Could not read BLOB into " + name + " as object.", e);
+                log.warn("Could not read BLOB into {} as object.", name, e);
             }
         } else if (RS_COUNT_RECORDS.equals(resultSetHandler)) {
             jmvars.put(name, blob.length() + " bytes");
@@ -352,7 +352,7 @@ public abstract class AbstractJDBCTestEl
                     jmvars.put(name, IOUtils.toString(is, ENCODING));
                 }
             } catch (IOException e) {
-                log.warn("Can't convert BLOB to String using " + ENCODING, e);
+                log.warn("Can't convert BLOB to String using {}", ENCODING, e);
             }
         }
     }
@@ -597,7 +597,7 @@ public abstract class AbstractJDBCTestEl
                 s.close();
             }
         } catch (SQLException e) {
-            log.warn("Error closing Statement " + (s != null ? s.toString() : "null"), e);
+            log.warn("Error closing Statement {}", (s != null ? s.toString() : "null"), e);
         }
     }
 

Modified: jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/config/DataSourceElement.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/config/DataSourceElement.java?rev=1781814&r1=1781813&r2=1781814&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/config/DataSourceElement.java
(original)
+++ jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/config/DataSourceElement.java
Sun Feb  5 21:51:30 2017
@@ -33,13 +33,13 @@ import org.apache.jmeter.testelement.Abs
 import org.apache.jmeter.testelement.TestStateListener;
 import org.apache.jmeter.threads.JMeterContextService;
 import org.apache.jmeter.threads.JMeterVariables;
-import org.apache.jorphan.logging.LoggingManager;
 import org.apache.jorphan.util.JOrphanUtils;
-import org.apache.log.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class DataSourceElement extends AbstractTestElement
     implements ConfigElement, TestStateListener, TestBean {
-    private static final Logger log = LoggingManager.getLoggerForClass();
+    private static final Logger log = LoggerFactory.getLogger(DataSourceElement.class);
 
     private static final long serialVersionUID = 234L;
 
@@ -78,18 +78,18 @@ public class DataSourceElement extends A
                 try {
                     dbcpDataSource.close();
                 } catch (SQLException ex) {
-                    log.error("Error closing pool:"+getName(), ex);
+                    log.error("Error closing pool: {}", getName(), ex);
                 }
             }
             dbcpDataSource = null;
         }
         if (perThreadPoolSet != null) {// in case
             for(BasicDataSource dsc : perThreadPoolSet){
-                log.debug("Closing pool: "+ getDataSourceName()+" @"+System.identityHashCode(dsc));
+                log.debug("Closing pool: {}@{}", getDataSourceName(), System.identityHashCode(dsc));
                 try {
                     dsc.close();
                 } catch (SQLException ex) {
-                    log.error("Error closing pool:"+getName(), ex);
+                    log.error("Error closing pool:{}", getName(), ex);
                 }
             }
             perThreadPoolSet=null;
@@ -110,7 +110,7 @@ public class DataSourceElement extends A
         if(JOrphanUtils.isBlank(poolName)) {
             throw new IllegalArgumentException("Variable Name must not be empty for element:"+getName());
         } else if (variables.getObject(poolName) != null) {
-            log.error("JDBC data source already defined for: "+poolName);
+            log.error("JDBC data source already defined for: {}", poolName);
         } else {
             String maxPool = getPoolMax();
             perThreadPoolSet = Collections.synchronizedSet(new HashSet<BasicDataSource>());
@@ -244,11 +244,7 @@ public class DataSourceElement extends A
             dataSource.setPassword(getPassword());
         }
 
-        // log is required to ensure errors are available
-        //source.enableLogging(new LogKitLogger(log));
-        if(log.isDebugEnabled()) {
-            log.debug("PoolConfiguration:"+this.dataSource);
-        }
+        log.debug("PoolConfiguration:{}", this.dataSource);
         return dataSource;
     }
 
@@ -288,7 +284,7 @@ public class DataSourceElement extends A
                 if (dsc == null){
                     dsc = initPool("1");
                     poolMap.put(getDataSourceName(),dsc);
-                    log.debug("Storing pool: "+getName()+" @"+System.identityHashCode(dsc));
+                    log.debug("Storing pool: {}@{}", getName(), System.identityHashCode(dsc));
                     perThreadPoolSet.add(dsc);
                 }
             }
@@ -299,11 +295,11 @@ public class DataSourceElement extends A
                     try {
                         // make sure setting the new isolation mode is done in an auto committed
transaction
                         conn.setTransactionIsolation(transactionIsolation);
-                        log.debug("Setting transaction isolation: " + transactionIsolation
+ " @"
-                                + System.identityHashCode(dsc));
+                        log.debug("Setting transaction isolation: {}@{}",
+                                    transactionIsolation, System.identityHashCode(dsc));
                     } catch (SQLException ex) {
-                        log.error("Could not set transaction isolation: " + transactionIsolation
+ " @"
-                                + System.identityHashCode(dsc));
+                        log.error("Could not set transaction isolation: {}@{}", 
+                                transactionIsolation, System.identityHashCode(dsc));
                     }   
                 }
             }

Modified: jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/config/DataSourceElementBeanInfo.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/config/DataSourceElementBeanInfo.java?rev=1781814&r1=1781813&r2=1781814&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/config/DataSourceElementBeanInfo.java
(original)
+++ jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/config/DataSourceElementBeanInfo.java
Sun Feb  5 21:51:30 2017
@@ -30,11 +30,11 @@ import java.util.Set;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.jmeter.testbeans.BeanInfoSupport;
 import org.apache.jmeter.testbeans.gui.TypeEditor;
-import org.apache.jorphan.logging.LoggingManager;
-import org.apache.log.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class DataSourceElementBeanInfo extends BeanInfoSupport {
-    private static final Logger log = LoggingManager.getLoggerForClass();
+    private static final Logger log = LoggerFactory.getLogger(DataSourceElementBeanInfo.class);
     private static Map<String,Integer> TRANSACTION_ISOLATION_MAP = new HashMap<>(5);
     static {
         // Will use default isolation

Modified: jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/processor/AbstractJDBCProcessor.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/processor/AbstractJDBCProcessor.java?rev=1781814&r1=1781813&r2=1781814&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/processor/AbstractJDBCProcessor.java
(original)
+++ jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/processor/AbstractJDBCProcessor.java
Sun Feb  5 21:51:30 2017
@@ -24,38 +24,34 @@ import java.sql.SQLException;
 
 import org.apache.jmeter.protocol.jdbc.AbstractJDBCTestElement;
 import org.apache.jmeter.protocol.jdbc.config.DataSourceElement;
-import org.apache.jorphan.logging.LoggingManager;
 import org.apache.jorphan.util.JOrphanUtils;
-import org.apache.log.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * As pre- and post-processors essentially do the same this class provides the implementation.
  */
 public abstract class AbstractJDBCProcessor extends AbstractJDBCTestElement {
     
-    private static final Logger log = LoggingManager.getLoggerForClass();
+    private static final Logger log = LoggerFactory.getLogger(AbstractJDBCProcessor.class);
 
-    private static final long serialVersionUID = 232L;
+    private static final long serialVersionUID = 233L;
 
     /**
      * Calls the JDBC code to be executed.
      */
     protected void process() {
-        Connection conn = null;
         if(JOrphanUtils.isBlank(getDataSource())) {
             throw new IllegalArgumentException("Variable Name must not be null in "+getName());
         }
-        try {
-            conn = DataSourceElement.getConnection(getDataSource());
+        try (Connection conn = DataSourceElement.getConnection(getDataSource())){
             execute(conn);
         } catch (SQLException ex) {
-            log.warn("SQL Problem in  "+ getName() + ": " + ex.toString());
+            log.warn("SQL Problem in {}: {}", getName(), ex.toString());
         } catch (IOException ex) {
-            log.warn("IO Problem in  "+ getName() + ": " + ex.toString());
+            log.warn("IO Problem in {}: {}"+ getName(), ex.toString());
         } catch (UnsupportedOperationException ex) {
-            log.warn("Execution Problem in "+ getName() + ": " + ex.toString());
-        } finally {
-            close(conn);
+            log.warn("Execution Problem in {}: {}", getName(), ex.toString());
         }
     }
 

Modified: jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/sampler/JDBCSampler.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/sampler/JDBCSampler.java?rev=1781814&r1=1781813&r2=1781814&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/sampler/JDBCSampler.java
(original)
+++ jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/sampler/JDBCSampler.java
Sun Feb  5 21:51:30 2017
@@ -34,9 +34,7 @@ import org.apache.jmeter.samplers.Sample
 import org.apache.jmeter.samplers.Sampler;
 import org.apache.jmeter.testbeans.TestBean;
 import org.apache.jmeter.testelement.TestElement;
-import org.apache.jorphan.logging.LoggingManager;
 import org.apache.jorphan.util.JOrphanUtils;
-import org.apache.log.Logger;
 
 /**
  * A sampler which understands JDBC database requests.
@@ -48,8 +46,6 @@ public class JDBCSampler extends Abstrac
     
     private static final long serialVersionUID = 234L;
     
-    private static final Logger log = LoggingManager.getLoggerForClass();
-
     /**
      * Creates a JDBCSampler.
      */
@@ -58,8 +54,6 @@ public class JDBCSampler extends Abstrac
 
     @Override
     public SampleResult sample(Entry e) {
-        log.debug("sampling jdbc");
-
         SampleResult res = new SampleResult();
         res.setSampleLabel(getName());
         res.setSamplerData(toString());



Mime
View raw message