Am 25. Januar 2017 13:32:56 MEZ schrieb [email protected]:
>Author: pmouawad
>Date: Wed Jan 25 12:32:56 2017
>New Revision: 1780178
>
>URL: http://svn.apache.org/viewvc?rev=1780178&view=rev
>Log:
>Bug 55652 - JavaSampler silently resets classname if class can not be
>found
>Fix Sonar error in a better way , thanks Felix
>Bugzilla Id: 55652
>
>Modified:
>jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/config/gui/JavaConfigGui.java
>
>Modified:
>jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/config/gui/JavaConfigGui.java
>URL:
>http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/config/gui/JavaConfigGui.java?rev=1780178&r1=1780177&r2=1780178&view=diff
>==============================================================================
>---
>jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/config/gui/JavaConfigGui.java
>(original)
>+++
>jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/config/gui/JavaConfigGui.java
>Wed Jan 25 12:32:56 2017
>@@ -248,7 +248,6 @@ public class JavaConfigGui extends Abstr
> }
>
> if(!classOk(className)) {
>- log.error("Error setting class:'"+className+"' in
>JavaSampler "+getName()+", check for a missing jar in your jmeter
>'search_paths' and 'plugin_dependency_paths' properties");
> warningLabel.setVisible(true);
> } else {
> warningLabel.setVisible(false);
Great, now we could just set the label directly without the if statement :)
warning label.set visible(!classOk(class name))
Regards,
Felix
>@@ -261,12 +260,14 @@ public class JavaConfigGui extends Abstr
> * @param className String class name
>* @return true if class is ok (exist in classpath and instanceof {@link
>JavaSamplerClient}
> */
>- private static boolean classOk(String className) {
>+ private boolean classOk(String className) {
> try {
>JavaSamplerClient client = (JavaSamplerClient) Class.forName(className,
>true,
> Thread.currentThread().getContextClassLoader()).newInstance();
> return client != null;
>- } catch (Exception ex) { // NOSONAR We already log this
>+ } catch (Exception ex) {
>+ log.error("Error creating class:'"+className+"' in
>JavaSampler "+getName()
>+ +", check for a missing jar in your jmeter
>'search_paths' and 'plugin_dependency_paths' properties");
> return false;
> }
> }