jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fschumac...@apache.org
Subject svn commit: r1779801 - in /jmeter/trunk: src/protocol/http/org/apache/jmeter/protocol/http/config/gui/ src/protocol/http/org/apache/jmeter/protocol/http/control/gui/ src/protocol/http/org/apache/jmeter/protocol/http/gui/ src/protocol/http/org/apache/jm...
Date Sun, 22 Jan 2017 12:47:30 GMT
Author: fschumacher
Date: Sun Jan 22 12:47:30 2017
New Revision: 1779801

URL: http://svn.apache.org/viewvc?rev=1779801&view=rev
Log:
Utilised Java 8 (and 7) features to tidy up code. Contributed by Graham Russell (graham at
ham1.co.uk). Part 1/8 of github pr #255

Modified:
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/config/gui/HttpDefaultsGui.java
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/gui/HttpTestSampleGui.java
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/gui/SoapSamplerGui.java
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/HTTPArgumentsPanel.java
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/ResourcesDownloader.java
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/HC4TrustAllSSLSocketFactory.java
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/LoopbackHttpClientSocketFactory.java
    jmeter/trunk/src/protocol/ldap/org/apache/jmeter/protocol/ldap/sampler/LDAPExtSampler.java
    jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/mail/sampler/MailFileFolder.java
    jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/mail/sampler/gui/MailReaderSamplerGui.java
    jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SecuritySettingsPanel.java
    jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SmtpPanel.java
    jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/config/gui/TCPConfigGui.java
    jmeter/trunk/xdocs/changes.xml

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/config/gui/HttpDefaultsGui.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/config/gui/HttpDefaultsGui.java?rev=1779801&r1=1779800&r2=1779801&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/config/gui/HttpDefaultsGui.java
(original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/config/gui/HttpDefaultsGui.java
Sun Jan 22 12:47:30 2017
@@ -296,21 +296,15 @@ public class HttpDefaultsGui extends Abs
         // retrieve Embedded resources
         retrieveEmbeddedResources = new JCheckBox(JMeterUtils.getResString("web_testing_retrieve_images"));
// $NON-NLS-1$
         // add a listener to activate or not concurrent dwn.
-        retrieveEmbeddedResources.addItemListener(new ItemListener() {
-            @Override
-            public void itemStateChanged(final ItemEvent e) {
-                if (e.getStateChange() == ItemEvent.SELECTED) { enableConcurrentDwn(true);
}
-                else { enableConcurrentDwn(false); }
-            }
+        retrieveEmbeddedResources.addItemListener(e -> {
+            if (e.getStateChange() == ItemEvent.SELECTED) { enableConcurrentDwn(true); }
+            else { enableConcurrentDwn(false); }
         });
         // Download concurrent resources
         concurrentDwn = new JCheckBox(JMeterUtils.getResString("web_testing_concurrent_download"));
// $NON-NLS-1$
-        concurrentDwn.addItemListener(new ItemListener() {
-            @Override
-            public void itemStateChanged(final ItemEvent e) {
-                if (retrieveEmbeddedResources.isSelected() && e.getStateChange()
== ItemEvent.SELECTED) { concurrentPool.setEnabled(true); }
-                else { concurrentPool.setEnabled(false); }
-            }
+        concurrentDwn.addItemListener(e -> {
+            if (retrieveEmbeddedResources.isSelected() && e.getStateChange() == ItemEvent.SELECTED)
{ concurrentPool.setEnabled(true); }
+            else { concurrentPool.setEnabled(false); }
         });
         concurrentPool = new JTextField(2); // 2 columns size
         concurrentPool.setMinimumSize(new Dimension(10, (int) concurrentPool.getPreferredSize().getHeight()));

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/gui/HttpTestSampleGui.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/gui/HttpTestSampleGui.java?rev=1779801&r1=1779800&r2=1779801&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/gui/HttpTestSampleGui.java
(original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/gui/HttpTestSampleGui.java
Sun Jan 22 12:47:30 2017
@@ -249,21 +249,15 @@ public class HttpTestSampleGui extends A
         // retrieve Embedded resources
         retrieveEmbeddedResources = new JCheckBox(JMeterUtils.getResString("web_testing_retrieve_images"));
// $NON-NLS-1$
         // add a listener to activate or not concurrent dwn.
-        retrieveEmbeddedResources.addItemListener(new ItemListener() {
-            @Override
-            public void itemStateChanged(final ItemEvent e) {
-                if (e.getStateChange() == ItemEvent.SELECTED) { enableConcurrentDwn(true);
}
-                else { enableConcurrentDwn(false); }
-            }
+        retrieveEmbeddedResources.addItemListener(e -> {
+            if (e.getStateChange() == ItemEvent.SELECTED) { enableConcurrentDwn(true); }
+            else { enableConcurrentDwn(false); }
         });
         // Download concurrent resources
         concurrentDwn = new JCheckBox(JMeterUtils.getResString("web_testing_concurrent_download"));
// $NON-NLS-1$
-        concurrentDwn.addItemListener(new ItemListener() {
-            @Override
-            public void itemStateChanged(final ItemEvent e) {
-                if (retrieveEmbeddedResources.isSelected() && e.getStateChange()
== ItemEvent.SELECTED) { concurrentPool.setEnabled(true); }
-                else { concurrentPool.setEnabled(false); }
-            }
+        concurrentDwn.addItemListener(e -> {
+            if (retrieveEmbeddedResources.isSelected() && e.getStateChange() == ItemEvent.SELECTED)
{ concurrentPool.setEnabled(true); }
+            else { concurrentPool.setEnabled(false); }
         });
         concurrentPool = new JTextField(2); // 2 column size
         concurrentPool.setMinimumSize(new Dimension(10, (int) concurrentPool.getPreferredSize().getHeight()));

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/gui/SoapSamplerGui.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/gui/SoapSamplerGui.java?rev=1779801&r1=1779800&r2=1779801&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/gui/SoapSamplerGui.java
(original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/gui/SoapSamplerGui.java
Sun Jan 22 12:47:30 2017
@@ -142,12 +142,7 @@ public class SoapSamplerGui extends Abst
         mainPanel.add(soapXml, BorderLayout.CENTER);
         mainPanel.add(soapXmlFile, BorderLayout.SOUTH);
 
-        sendSoapAction.addActionListener(new ActionListener() {
-            @Override
-            public void actionPerformed(ActionEvent e) {
-                soapAction.setEnabled(sendSoapAction.isSelected());
-            }
-            });
+        sendSoapAction.addActionListener(e -> soapAction.setEnabled(sendSoapAction.isSelected()));
 
         add(mainPanel, BorderLayout.CENTER);
     }

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/HTTPArgumentsPanel.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/HTTPArgumentsPanel.java?rev=1779801&r1=1779800&r2=1779801&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/HTTPArgumentsPanel.java
(original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/HTTPArgumentsPanel.java
Sun Jan 22 12:47:30 2017
@@ -172,12 +172,7 @@ public class HTTPArgumentsPanel extends
         JTable table = getTable();
         final JPopupMenu popupMenu = new JPopupMenu();
         JMenuItem variabilizeItem = new JMenuItem(JMeterUtils.getResString("transform_into_variable"));
-        variabilizeItem.addActionListener(new ActionListener() {
-            @Override
-            public void actionPerformed(ActionEvent e) {
-                transformNameIntoVariable();
-            }
-        });
+        variabilizeItem.addActionListener(e -> transformNameIntoVariable());
         popupMenu.add(variabilizeItem);
         table.setComponentPopupMenu(popupMenu);
     }

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java?rev=1779801&r1=1779800&r2=1779801&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
(original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
Sun Jan 22 12:47:30 2017
@@ -621,22 +621,14 @@ public class HTTPHC4Impl extends HTTPHCA
         AuthManager authManager = getAuthManager();
         if (authManager != null) {
             Subject subject = authManager.getSubjectForUrl(url);
-            if(subject != null) {
+            if (subject != null) {
                 try {
                     return Subject.doAs(subject,
-                            new PrivilegedExceptionAction<HttpResponse>() {
-    
-                                @Override
-                                public HttpResponse run() throws Exception {
-                                    return httpClient.execute(httpRequest,
-                                            localContext);
-                                }
-                            });
+                            (PrivilegedExceptionAction<HttpResponse>) () ->
+                                    httpClient.execute(httpRequest, localContext));
                 } catch (PrivilegedActionException e) {
-                    log.error(
-                            "Can't execute httpRequest with subject:"+subject,
-                            e);
-                    throw new RuntimeException("Can't execute httpRequest with subject:"+subject,
e);
+                    log.error("Can't execute httpRequest with subject:" + subject, e);
+                    throw new RuntimeException("Can't execute httpRequest with subject:"
+ subject, e);
                 }
             }
         }

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/ResourcesDownloader.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/ResourcesDownloader.java?rev=1779801&r1=1779800&r2=1779801&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/ResourcesDownloader.java
(original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/ResourcesDownloader.java
Sun Jan 22 12:47:30 2017
@@ -91,21 +91,17 @@ public class ResourcesDownloader {
     
     private void init() {
         LOG.info("Creating ResourcesDownloader with keepalive_inseconds:"+THREAD_KEEP_ALIVE_TIME);
-        ThreadPoolExecutor exec = new ThreadPoolExecutor(
+        concurrentExecutor = new ThreadPoolExecutor(
                 MIN_POOL_SIZE, MAX_POOL_SIZE, THREAD_KEEP_ALIVE_TIME, TimeUnit.SECONDS,
-                new SynchronousQueue<Runnable>(),
-                new ThreadFactory() {
-                    @Override
-                    public Thread newThread(final Runnable r) {
-                        Thread t = new Thread(r);
-                        t.setName("ResDownload-" + t.getName()); //$NON-NLS-1$
-                        t.setDaemon(true);
-                        return t;
-                    }
+                new SynchronousQueue<>(),
+                r -> {
+                    Thread t = new Thread(r);
+                    t.setName("ResDownload-" + t.getName()); //$NON-NLS-1$
+                    t.setDaemon(true);
+                    return t;
                 }) {
 
         };
-        concurrentExecutor = exec;
     }
     
     /**

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/HC4TrustAllSSLSocketFactory.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/HC4TrustAllSSLSocketFactory.java?rev=1779801&r1=1779800&r2=1779801&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/HC4TrustAllSSLSocketFactory.java
(original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/HC4TrustAllSSLSocketFactory.java
Sun Jan 22 12:47:30 2017
@@ -38,12 +38,7 @@ import org.apache.jmeter.util.JsseSSLMan
 
 public class HC4TrustAllSSLSocketFactory extends SSLSocketFactory {
 
-    private static final TrustStrategy TRUSTALL = new TrustStrategy(){
-        @Override
-        public boolean isTrusted(X509Certificate[] chain, String authType) {
-            return true;
-        }
-    };
+    private static final TrustStrategy TRUSTALL = (chain, authType) -> true;
     private javax.net.ssl.SSLSocketFactory factory;
 
     /**

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/LoopbackHttpClientSocketFactory.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/LoopbackHttpClientSocketFactory.java?rev=1779801&r1=1779800&r2=1779801&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/LoopbackHttpClientSocketFactory.java
(original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/LoopbackHttpClientSocketFactory.java
Sun Jan 22 12:47:30 2017
@@ -80,19 +80,16 @@ public class LoopbackHttpClientSocketFac
         Protocol.registerProtocol(LOOPBACK, new Protocol(LOOPBACK,new LoopbackHttpClientSocketFactory(),1));
 
         // Now allow the URL handling to work.
-        URLStreamHandlerFactory ushf = new URLStreamHandlerFactory(){
-            @Override
-            public URLStreamHandler createURLStreamHandler(String protocol) {
-                if (protocol.equalsIgnoreCase(LOOPBACK)){
-                    return new URLStreamHandler(){
-                        @Override
-                        protected URLConnection openConnection(URL u) throws IOException
{
-                            return null;// not needed for HttpClient
-                        }
-                    };
-                }
-                return null;
+        URLStreamHandlerFactory ushf = protocol -> {
+            if (protocol.equalsIgnoreCase(LOOPBACK)){
+                return new URLStreamHandler(){
+                    @Override
+                    protected URLConnection openConnection(URL u) throws IOException {
+                        return null;// not needed for HttpClient
+                    }
+                };
             }
+            return null;
         };
 
         java.net.URL.setURLStreamHandlerFactory(ushf);

Modified: jmeter/trunk/src/protocol/ldap/org/apache/jmeter/protocol/ldap/sampler/LDAPExtSampler.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/ldap/org/apache/jmeter/protocol/ldap/sampler/LDAPExtSampler.java?rev=1779801&r1=1779800&r2=1779801&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/ldap/org/apache/jmeter/protocol/ldap/sampler/LDAPExtSampler.java
(original)
+++ jmeter/trunk/src/protocol/ldap/org/apache/jmeter/protocol/ldap/sampler/LDAPExtSampler.java
Sun Jan 22 12:47:30 2017
@@ -950,16 +950,11 @@ public class LDAPExtSampler extends Abst
     }
 
     private void sortAttributes(final List<Attribute> sortedAttrs) {
-        Collections.sort(sortedAttrs, new Comparator<Attribute>()
-        {
-            @Override
-            public int compare(Attribute o1, Attribute o2)
-            {
-                String nm1 = o1.getID();
-                String nm2 = o2.getID();
+        sortedAttrs.sort((o1, o2) -> {
+            String nm1 = o1.getID();
+            String nm2 = o2.getID();
 
-                return nm1.compareTo(nm2);
-            }
+            return nm1.compareTo(nm2);
         });
     }
 

Modified: jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/mail/sampler/MailFileFolder.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/mail/sampler/MailFileFolder.java?rev=1779801&r1=1779800&r2=1779801&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/mail/sampler/MailFileFolder.java
(original)
+++ jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/mail/sampler/MailFileFolder.java
Sun Jan 22 12:47:30 2017
@@ -41,13 +41,7 @@ public class MailFileFolder extends Fold
     private boolean isOpen;
     private final File folderPath;// Parent folder (or single message file)
     private final boolean isFile;
-    private static final FilenameFilter FILENAME_FILTER = new FilenameFilter(){
-        @Override
-        public boolean accept(File dir, String name) {
-            return name.matches(FILENAME_REGEX);
-        }
-
-    };
+    private static final FilenameFilter FILENAME_FILTER = (dir, name) -> name.matches(FILENAME_REGEX);
 
     public MailFileFolder(Store store, String path) {
         super(store);

Modified: jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/mail/sampler/gui/MailReaderSamplerGui.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/mail/sampler/gui/MailReaderSamplerGui.java?rev=1779801&r1=1779800&r2=1779801&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/mail/sampler/gui/MailReaderSamplerGui.java
(original)
+++ jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/mail/sampler/gui/MailReaderSamplerGui.java
Sun Jan 22 12:47:30 2017
@@ -213,21 +213,15 @@ public class MailReaderSamplerGui extend
         numMessagesPanel.add(new JLabel(numMessagesLabel));
         ButtonGroup nmbg = new ButtonGroup();
         allMessagesButton = new JRadioButton(allMessagesLabel);
-        allMessagesButton.addChangeListener(new ChangeListener() {
-            @Override
-            public void stateChanged(ChangeEvent e) {
-                if (allMessagesButton.isSelected()) {
-                    someMessagesField.setEnabled(false);
-                }
+        allMessagesButton.addChangeListener(e -> {
+            if (allMessagesButton.isSelected()) {
+                someMessagesField.setEnabled(false);
             }
         });
         someMessagesButton = new JRadioButton();
-        someMessagesButton.addChangeListener(new ChangeListener() {
-            @Override
-            public void stateChanged(ChangeEvent e) {
-                if (someMessagesButton.isSelected()) {
-                    someMessagesField.setEnabled(true);
-                }
+        someMessagesButton.addChangeListener(e -> {
+            if (someMessagesButton.isSelected()) {
+                someMessagesField.setEnabled(true);
             }
         });
         nmbg.add(allMessagesButton);

Modified: jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SecuritySettingsPanel.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SecuritySettingsPanel.java?rev=1779801&r1=1779800&r2=1779801&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SecuritySettingsPanel.java
(original)
+++ jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SecuritySettingsPanel.java
Sun Jan 22 12:47:30 2017
@@ -116,35 +116,15 @@ public class SecuritySettingsPanel exten
         gridBagConstraints.gridy = 0;
         this.add(rbUseStartTLS, gridBagConstraints);
 
-        rbUseNone.addItemListener(new ItemListener() {
-            @Override
-            public void itemStateChanged(ItemEvent evt) {
-                rbSecuritySettingsItemStateChanged(evt);
-            }
-        });
-        rbUseSSL.addItemListener(new ItemListener() {
-            @Override
-            public void itemStateChanged(ItemEvent evt) {
-                rbSecuritySettingsItemStateChanged(evt);
-            }
-        });
-        rbUseStartTLS.addItemListener(new ItemListener() {
-            @Override
-            public void itemStateChanged(ItemEvent evt) {
-                rbSecuritySettingsItemStateChanged(evt);
-            }
-        });
+        rbUseNone.addItemListener(this::rbSecuritySettingsItemStateChanged);
+        rbUseSSL.addItemListener(this::rbSecuritySettingsItemStateChanged);
+        rbUseStartTLS.addItemListener(this::rbSecuritySettingsItemStateChanged);
 
         cbTrustAllCerts.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
         cbTrustAllCerts.setMargin(new java.awt.Insets(0, 0, 0, 0));
         cbTrustAllCerts.setEnabled(false);
         cbTrustAllCerts.setToolTipText(JMeterUtils.getResString("smtp_trustall_tooltip"));
// $NON-NLS-1$
-        cbTrustAllCerts.addActionListener(new ActionListener() {
-            @Override
-            public void actionPerformed(ActionEvent evt) {
-                cbTrustAllCertsActionPerformed(evt);
-            }
-        });
+        cbTrustAllCerts.addActionListener(this::cbTrustAllCertsActionPerformed);
 
         gridBagConstraints.gridx = 0;
         gridBagConstraints.gridy = 1;
@@ -153,12 +133,7 @@ public class SecuritySettingsPanel exten
         cbEnforceStartTLS.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
         cbEnforceStartTLS.setMargin(new java.awt.Insets(0, 0, 0, 0));
         cbEnforceStartTLS.setEnabled(false);
-        cbEnforceStartTLS.addActionListener(new ActionListener() {
-                    @Override
-                    public void actionPerformed(ActionEvent evt) {
-                        cbEnforceStartTLSActionPerformed(evt);
-                    }
-                });
+        cbEnforceStartTLS.addActionListener(this::cbEnforceStartTLSActionPerformed);
         cbEnforceStartTLS.setToolTipText(JMeterUtils.getResString("smtp_enforcestarttls_tooltip"));
// $NON-NLS-1$
 
         gridBagConstraints.gridx = 2;
@@ -168,12 +143,7 @@ public class SecuritySettingsPanel exten
         cbUseLocalTrustStore.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
         cbUseLocalTrustStore.setMargin(new java.awt.Insets(0, 0, 0, 0));
         cbUseLocalTrustStore.setEnabled(false);
-        cbUseLocalTrustStore.addActionListener(new ActionListener() {
-                    @Override
-                    public void actionPerformed(ActionEvent evt) {
-                        cbUseLocalTrustStoreActionPerformed(evt);
-                    }
-                });
+        cbUseLocalTrustStore.addActionListener(this::cbUseLocalTrustStoreActionPerformed);
 
         cbUseLocalTrustStore.setToolTipText(JMeterUtils.getResString("smtp_usetruststore_tooltip"));
// $NON-NLS-1$
 

Modified: jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SmtpPanel.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SmtpPanel.java?rev=1779801&r1=1779800&r2=1779801&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SmtpPanel.java
(original)
+++ jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SmtpPanel.java
Sun Jan 22 12:47:30 2017
@@ -570,12 +570,7 @@ public class SmtpPanel extends JPanel {
         cbPlainBody = new JCheckBox(JMeterUtils.getResString("smtp_plainbody")); // $NON-NLS-1$
         
         cbSuppressSubject = new JCheckBox(JMeterUtils.getResString("smtp_suppresssubj"));
// $NON-NLS-1$
-        cbSuppressSubject.addChangeListener(new ChangeListener() {
-            @Override
-            public void stateChanged(ChangeEvent evt) {
-                emptySubjectActionPerformed(evt);
-            }
-        });
+        cbSuppressSubject.addChangeListener(this::emptySubjectActionPerformed);
 
         cbUseAuth = new JCheckBox(JMeterUtils.getResString("smtp_useauth")); // $NON-NLS-1$
 
@@ -591,19 +586,9 @@ public class SmtpPanel extends JPanel {
         emlBrowseButton = new JButton(JMeterUtils.getResString("browse")); // $NON-NLS-1$
 
         attachmentFileChooser
-                .addActionListener(new ActionListener() {
-                    @Override
-                    public void actionPerformed(ActionEvent evt) {
-                        attachmentFolderFileChooserActionPerformed(evt);
-                    }
-                });
-
-        emlFileChooser.addActionListener(new ActionListener() {
-            @Override
-            public void actionPerformed(ActionEvent evt) {
-                emlFileChooserActionPerformed(evt);
-            }
-        });
+                .addActionListener(this::attachmentFolderFileChooserActionPerformed);
+
+        emlFileChooser.addActionListener(this::emlFileChooserActionPerformed);
 
         setLayout(new GridBagLayout());
 
@@ -720,12 +705,7 @@ public class SmtpPanel extends JPanel {
 
         cbUseAuth.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
         cbUseAuth.setMargin(new java.awt.Insets(0, 0, 0, 0));
-        cbUseAuth.addActionListener(new ActionListener() {
-            @Override
-            public void actionPerformed(ActionEvent evt) {
-                cbUseAuthActionPerformed(evt);
-            }
-        });
+        cbUseAuth.addActionListener(this::cbUseAuthActionPerformed);
         gridBagConstraints.gridx = 0;
         gridBagConstraints.gridy = 0;
         panelAuthSettings.add(cbUseAuth, gridBagConstraints);
@@ -804,12 +784,7 @@ public class SmtpPanel extends JPanel {
          */
 
         addHeaderFieldButton = new JButton(JMeterUtils.getResString("smtp_header_add"));
// $NON-NLS-1$
-        addHeaderFieldButton.addActionListener(new ActionListener() {
-            @Override
-            public void actionPerformed(ActionEvent evt) {
-                addHeaderActionPerformed(evt);
-            }
-        });
+        addHeaderFieldButton.addActionListener(this::addHeaderActionPerformed);
         headerFieldName = new JLabel(JMeterUtils.getResString("smtp_header_name")); // $NON-NLS-1$
         headerFieldValue = new JLabel(JMeterUtils.getResString("smtp_header_value")); //
$NON-NLS-1$
         headerFieldsPanel = new JPanel(new GridBagLayout());
@@ -862,12 +837,7 @@ public class SmtpPanel extends JPanel {
         panelMessageSettings.add(tfAttachment, gridBagConstraints);
         tfAttachment.setToolTipText(JMeterUtils.getResString("smtp_attach_file_tooltip"));
// $NON-NLS-1$
 
-        browseButton.addActionListener(new ActionListener() {
-            @Override
-            public void actionPerformed(ActionEvent evt) {
-                browseButtonActionPerformed(evt);
-            }
-        });
+        browseButton.addActionListener(this::browseButtonActionPerformed);
 
         gridBagConstraints.gridx = 2;
         gridBagConstraints.gridy = 4;
@@ -875,12 +845,7 @@ public class SmtpPanel extends JPanel {
         panelMessageSettings.add(browseButton, gridBagConstraints);
 
         cbUseEmlMessage.setSelected(false);
-        cbUseEmlMessage.addActionListener(new ActionListener() {
-            @Override
-            public void actionPerformed(ActionEvent evt) {
-                cbUseEmlMessageActionPerformed(evt);
-            }
-        });
+        cbUseEmlMessage.addActionListener(this::cbUseEmlMessageActionPerformed);
 
         gridBagConstraints.gridx = 0;
         gridBagConstraints.gridy = 5;
@@ -893,12 +858,7 @@ public class SmtpPanel extends JPanel {
         tfEmlMessage.setEnabled(false);
         panelMessageSettings.add(tfEmlMessage, gridBagConstraints);
 
-        emlBrowseButton.addActionListener(new ActionListener() {
-            @Override
-            public void actionPerformed(ActionEvent evt) {
-                emlBrowseButtonActionPerformed(evt);
-            }
-        });
+        emlBrowseButton.addActionListener(this::emlBrowseButtonActionPerformed);
         emlBrowseButton.setEnabled(false);
 
         gridBagConstraints.gridx = 2;
@@ -1092,12 +1052,7 @@ public class SmtpPanel extends JPanel {
         headerFields.put(nameTF, valueTF);
         removeButtons.put(removeButton, nameTF);
 
-        removeButton.addActionListener(new ActionListener() {
-            @Override
-            public void actionPerformed(ActionEvent evt) {
-                removeHeaderActionPerformed(evt);
-            }
-        });
+        removeButton.addActionListener(this::removeHeaderActionPerformed);
 
         GridBagConstraints gridBagConstraints = new GridBagConstraints();
         gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);

Modified: jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/config/gui/TCPConfigGui.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/config/gui/TCPConfigGui.java?rev=1779801&r1=1779800&r2=1779801&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/config/gui/TCPConfigGui.java
(original)
+++ jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/config/gui/TCPConfigGui.java
Sun Jan 22 12:47:30 2017
@@ -161,14 +161,11 @@ public class TCPConfigGui extends Abstra
         JLabel label = new JLabel(JMeterUtils.getResString("reuseconnection")); //$NON-NLS-1$
 
         reUseConnection = new JCheckBox("", true);
-        reUseConnection.addItemListener(new ItemListener() {
-            @Override
-            public void itemStateChanged(final ItemEvent e) {
-                if (e.getStateChange() == ItemEvent.SELECTED) {
-                    closeConnection.setEnabled(true);
-                } else {
-                    closeConnection.setEnabled(false);
-                }
+        reUseConnection.addItemListener(e -> {
+            if (e.getStateChange() == ItemEvent.SELECTED) {
+                closeConnection.setEnabled(true);
+            } else {
+                closeConnection.setEnabled(false);
             }
         });
         label.setLabelFor(reUseConnection);

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1779801&r1=1779800&r2=1779801&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml [utf-8] (original)
+++ jmeter/trunk/xdocs/changes.xml [utf-8] Sun Jan 22 12:47:30 2017
@@ -172,6 +172,7 @@ JMeter now requires Java 8. Ensure you u
     <li>Updated to slf4j-api 1.7.22 (from 1.7.21)</li>
     <li>Updated to asm 5.2 (from 5.1)</li>
     <li>Converted the old pdf tutorials to xml.</li>
+    <li><pr>255</pr>Utilised Java 8 (and 7) features to tidy up code. Contributed
by Graham Russell (graham at ham1.co.uk)</li>
 </ul>
 
  <!-- =================== Bug fixes =================== -->
@@ -241,6 +242,7 @@ JMeter now requires Java 8. Ensure you u
 <li>Maxime Chassagneux (maxime.chassagneux at gmail.com)</li>
 <li>忻隆 (298015902 at qq.com)</li>
 <li><a href="http://ubikloadpack.com">Ubik Load Pack</a></li>
+<li>Graham Russell (graham at ham1.co.uk)</li>
 </ul>
 <p>We also thank bug reporters who helped us improve JMeter. <br/>
 For this release we want to give special thanks to the following reporters for the clear
reports and tests made after our fixes:</p>



Mime
View raw message