jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fschumac...@apache.org
Subject svn commit: r1847979 - in /jmeter/trunk/src: jorphan/org/apache/jorphan/gui/ jorphan/org/apache/jorphan/reflect/ protocol/http/org/apache/jmeter/protocol/http/proxy/ protocol/java/org/apache/jmeter/protocol/java/sampler/ protocol/tcp/org/apache/jmeter/...
Date Sun, 02 Dec 2018 11:21:33 GMT
Author: fschumacher
Date: Sun Dec  2 11:21:32 2018
New Revision: 1847979

URL: http://svn.apache.org/viewvc?rev=1847979&view=rev
Log:
Replace calls to deprecated Class#newInstance method

Part of #435 and Bugzilla Id: 62972

Modified:
    jmeter/trunk/src/jorphan/org/apache/jorphan/gui/ObjectTableModel.java
    jmeter/trunk/src/jorphan/org/apache/jorphan/reflect/ClassTools.java
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/Daemon.java
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/SamplerCreatorFactory.java
    jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/sampler/JavaSampler.java
    jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/sampler/TCPSampler.java

Modified: jmeter/trunk/src/jorphan/org/apache/jorphan/gui/ObjectTableModel.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/jorphan/org/apache/jorphan/gui/ObjectTableModel.java?rev=1847979&r1=1847978&r2=1847979&view=diff
==============================================================================
--- jmeter/trunk/src/jorphan/org/apache/jorphan/gui/ObjectTableModel.java (original)
+++ jmeter/trunk/src/jorphan/org/apache/jorphan/gui/ObjectTableModel.java Sun Dec  2 11:21:32
2018
@@ -257,11 +257,8 @@ public class ObjectTableModel extends De
         Object value;
         if (_value == null && objectClass != null) {
             try {
-                value = objectClass.newInstance();
-            } catch (InstantiationException e) {
-                log.error("Cannot create instance of class "+objectClass.getName(),e);
-                return false;
-            } catch (IllegalAccessException e) {
+                value = objectClass.getDeclaredConstructor().newInstance();
+            } catch (ReflectiveOperationException e) {
                 log.error("Cannot create instance of class "+objectClass.getName(),e);
                 return false;
             }

Modified: jmeter/trunk/src/jorphan/org/apache/jorphan/reflect/ClassTools.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/jorphan/org/apache/jorphan/reflect/ClassTools.java?rev=1847979&r1=1847978&r2=1847979&view=diff
==============================================================================
--- jmeter/trunk/src/jorphan/org/apache/jorphan/reflect/ClassTools.java (original)
+++ jmeter/trunk/src/jorphan/org/apache/jorphan/reflect/ClassTools.java Sun Dec  2 11:21:32
2018
@@ -41,9 +41,8 @@ public class ClassTools {
     public static Object construct(String className) throws JMeterException {
         Object instance = null;
         try {
-            instance = ClassUtils.getClass(className).newInstance();
-        } catch (ClassNotFoundException | IllegalAccessException
-                | InstantiationException e) {
+            instance = ClassUtils.getClass(className).getDeclaredConstructor().newInstance();
+        } catch (IllegalArgumentException | ReflectiveOperationException | SecurityException
e) {
             throw new JMeterException(e);
         }
         return instance;

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/Daemon.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/Daemon.java?rev=1847979&r1=1847978&r2=1847979&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/Daemon.java (original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/Daemon.java Sun Dec
 2 11:21:32 2018
@@ -128,7 +128,7 @@ public class Daemon extends Thread imple
                     Socket clientSocket = mainSocket.accept();
                     if (running) {
                         // Pass request to new proxy thread
-                        Proxy thd = proxyClass.newInstance();
+                        Proxy thd = proxyClass.getDeclaredConstructor().newInstance();
                         thd.configure(clientSocket, target, pageEncodings, formEncodings);
                         thd.start();
                     }

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/SamplerCreatorFactory.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/SamplerCreatorFactory.java?rev=1847979&r1=1847978&r2=1847979&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/SamplerCreatorFactory.java
(original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/SamplerCreatorFactory.java
Sun Dec  2 11:21:32 2018
@@ -61,7 +61,7 @@ public class SamplerCreatorFactory {
                         if(log.isDebugEnabled()) {
                             log.debug("Instantiating: {}", commandClass.getName());
                         }
-                        SamplerCreator creator = (SamplerCreator) commandClass.newInstance();
+                        SamplerCreator creator = (SamplerCreator) commandClass.getDeclaredConstructor().newInstance();
                         String[] contentTypes = creator.getManagedContentTypes();
                         for (String contentType : contentTypes) {
                             if(log.isDebugEnabled()) {

Modified: jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/sampler/JavaSampler.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/sampler/JavaSampler.java?rev=1847979&r1=1847978&r2=1847979&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/sampler/JavaSampler.java
(original)
+++ jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/sampler/JavaSampler.java
Sun Dec  2 11:21:32 2018
@@ -219,7 +219,7 @@ public class JavaSampler extends Abstrac
         }
         JavaSamplerClient client;
         try {
-            client = (JavaSamplerClient) javaClass.newInstance();
+            client = (JavaSamplerClient) javaClass.getDeclaredConstructor().newInstance();
 
             if (log.isDebugEnabled()) {
                 log.debug(whoAmI() + "\tCreated:\t" + getClassname() + "@"

Modified: jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/sampler/TCPSampler.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/sampler/TCPSampler.java?rev=1847979&r1=1847978&r2=1847979&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/sampler/TCPSampler.java (original)
+++ jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/sampler/TCPSampler.java Sun
Dec  2 11:21:32 2018
@@ -334,7 +334,7 @@ public class TCPSampler extends Abstract
             return null;
         }
         try {
-            tcpClient = (TCPClient) javaClass.newInstance();
+            tcpClient = (TCPClient) javaClass.getDeclaredConstructor().newInstance();
             if (getPropertyAsString(EOL_BYTE, "").length()>0){
                 tcpClient.setEolByte(getEolByte());
                 log.info("Using eolByte={}", getEolByte());



Mime
View raw message