You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by fs...@apache.org on 2019/10/03 12:06:54 UTC

[jmeter] 01/02: Anonymous type can be replaced with lambda + formatting along the way

This is an automated email from the ASF dual-hosted git repository.

fschumacher pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jmeter.git

commit b2d497f36cb8eb057939138502dd2b7fe3c3e6ff
Author: Graham Russell <gr...@ham1.co.uk>
AuthorDate: Thu Oct 3 12:04:46 2019 +0100

    Anonymous type can be replaced with lambda + formatting along the way
---
 .../java/org/apache/jmeter/visualizers/Graph.java  |  13 ++-
 .../jmeter/visualizers/MailerVisualizer.java       |  13 ++-
 .../jmeter/visualizers/PropertyControlGui.java     |  15 ++--
 .../visualizers/RespTimeGraphVisualizer.java       |  84 ++++++++---------
 .../PreciseThroughputTimerTest.java                |  14 +--
 .../jmeter/gui/tree/JMeterTreeTransferHandler.java |  19 +---
 .../org/apache/jmeter/report/core/Converters.java  | 100 +++++++--------------
 .../java/org/apache/jmeter/swing/HtmlPane.java     |  25 +++---
 .../jmeter/visualizers/gui/AbstractVisualizer.java |  29 +++---
 .../java/org/apache/jorphan/gui/MenuScroller.java  |  12 +--
 .../jmeter/protocol/http/sampler/HTTPHC4Impl.java  |  95 ++++++--------------
 .../jmeter/protocol/java/sampler/JUnitSampler.java |  36 +++-----
 12 files changed, 156 insertions(+), 299 deletions(-)

diff --git a/src/components/src/main/java/org/apache/jmeter/visualizers/Graph.java b/src/components/src/main/java/org/apache/jmeter/visualizers/Graph.java
index 7d596e2..0d8b1ad 100644
--- a/src/components/src/main/java/org/apache/jmeter/visualizers/Graph.java
+++ b/src/components/src/main/java/org/apache/jmeter/visualizers/Graph.java
@@ -177,14 +177,11 @@ public class Graph extends JComponent implements Scrollable, Clearable {
         }
         final long xPos = model.getCount();
 
-        SwingUtilities.invokeLater(new Runnable() {
-            @Override
-            public void run() {
-                Graphics g = getGraphics();
-
-                if (g != null) {
-                    drawSample(xPos, oneSample, g);
-                }
+        SwingUtilities.invokeLater(() -> {
+            Graphics g = getGraphics();
+
+            if (g != null) {
+                drawSample(xPos, oneSample, g);
             }
         });
     }
diff --git a/src/components/src/main/java/org/apache/jmeter/visualizers/MailerVisualizer.java b/src/components/src/main/java/org/apache/jmeter/visualizers/MailerVisualizer.java
index 3434b65..6b196bc 100644
--- a/src/components/src/main/java/org/apache/jmeter/visualizers/MailerVisualizer.java
+++ b/src/components/src/main/java/org/apache/jmeter/visualizers/MailerVisualizer.java
@@ -122,14 +122,11 @@ public class MailerVisualizer extends AbstractVisualizer implements ActionListen
     @Override
     public void add(final SampleResult res) {
         if (getModel() != null) {
-            JMeterUtils.runSafe(false, new Runnable() {
-                @Override
-                public void run() {
-                    MailerModel model = ((MailerResultCollector) getModel()).getMailerModel();
-                    // method called by add is synchronized
-                    model.add(res);//this is a different model from the one used by the result collector
-                    updateVisualizer(model);
-                }
+            JMeterUtils.runSafe(false, () -> {
+                MailerModel model = ((MailerResultCollector) getModel()).getMailerModel();
+                // method called by add is synchronized
+                model.add(res);//this is a different model from the one used by the result collector
+                updateVisualizer(model);
             });
         }
     }
diff --git a/src/components/src/main/java/org/apache/jmeter/visualizers/PropertyControlGui.java b/src/components/src/main/java/org/apache/jmeter/visualizers/PropertyControlGui.java
index d7d88d9..58d6a3d 100644
--- a/src/components/src/main/java/org/apache/jmeter/visualizers/PropertyControlGui.java
+++ b/src/components/src/main/java/org/apache/jmeter/visualizers/PropertyControlGui.java
@@ -26,8 +26,6 @@ import java.awt.event.ActionListener;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
@@ -133,18 +131,15 @@ public class PropertyControlGui extends AbstractConfigGui implements
         }
         Set<Map.Entry<Object, Object>> s = p.entrySet();
         List<Map.Entry<Object, Object>> al = new ArrayList<>(s);
-        Collections.sort(al, new Comparator<Map.Entry<Object, Object>>(){
-            @Override
-            public int compare(Map.Entry<Object, Object> o1, Map.Entry<Object, Object> o2) {
-                String m1 = (String) o1.getKey();
-                String m2 = (String) o2.getKey();
-                return m1.compareTo(m2);
-            }
+        al.sort((o1, o2) -> {
+            String m1 = (String) o1.getKey();
+            String m2 = (String) o2.getKey();
+            return m1.compareTo(m2);
         });
+
         for (Map.Entry<Object, Object> row : al) {
             tableModel.addRow(row);
         }
-
     }
 
     @Override
diff --git a/src/components/src/main/java/org/apache/jmeter/visualizers/RespTimeGraphVisualizer.java b/src/components/src/main/java/org/apache/jmeter/visualizers/RespTimeGraphVisualizer.java
index 4a55430..8e88665 100644
--- a/src/components/src/main/java/org/apache/jmeter/visualizers/RespTimeGraphVisualizer.java
+++ b/src/components/src/main/java/org/apache/jmeter/visualizers/RespTimeGraphVisualizer.java
@@ -50,7 +50,6 @@ import javax.swing.SwingConstants;
 import javax.swing.UIManager;
 import javax.swing.border.Border;
 import javax.swing.border.EmptyBorder;
-import javax.swing.event.ChangeEvent;
 import javax.swing.event.ChangeListener;
 
 import org.apache.commons.lang3.ArrayUtils;
@@ -302,44 +301,41 @@ public class RespTimeGraphVisualizer extends AbstractVisualizer implements Actio
         if ((matcher == null) || (matcher.find())) {
             final long startTimeMS = sampleResult.getStartTime();
             final long startTimeInterval = startTimeMS / intervalValue;
-            JMeterUtils.runSafe(false, new Runnable() {
-                @Override
-                public void run() {
-                    synchronized (lock) {
-                        // Use for x-axis scale
-                        if (startTimeInterval < minStartTime) {
-                            minStartTime = startTimeInterval;
-                        } else if (startTimeInterval > maxStartTime) {
-                            maxStartTime = startTimeInterval;
-                        }
-                        // Generate x-axis label and associated color
-                        if (!seriesNames.containsKey(sampleLabel)) {
-                            seriesNames.put(sampleLabel,
-                                    new RespTimeGraphLineBean(sampleLabel, listColors.get(colorIdx++)));
-                            // reset colors index
-                            if (colorIdx >= listColors.size()) {
-                                colorIdx = 0;
-                            }
+            JMeterUtils.runSafe(false, () -> {
+                synchronized (lock) {
+                    // Use for x-axis scale
+                    if (startTimeInterval < minStartTime) {
+                        minStartTime = startTimeInterval;
+                    } else if (startTimeInterval > maxStartTime) {
+                        maxStartTime = startTimeInterval;
+                    }
+                    // Generate x-axis label and associated color
+                    if (!seriesNames.containsKey(sampleLabel)) {
+                        seriesNames.put(sampleLabel,
+                                new RespTimeGraphLineBean(sampleLabel, listColors.get(colorIdx++)));
+                        // reset colors index
+                        if (colorIdx >= listColors.size()) {
+                            colorIdx = 0;
                         }
-                        // List of value by sampler
-                        Map<Long, StatCalculatorLong> subList = pList.get(sampleLabel);
-                        final Long startTimeIntervalLong = Long.valueOf(startTimeInterval);
-                        if (subList != null) {
-                            long respTime = sampleResult.getTime();
-                            StatCalculatorLong value = subList.get(startTimeIntervalLong);
-                            if (value==null) {
-                                value = new StatCalculatorLong();
-                                subList.put(startTimeIntervalLong, value);
-                            }
-                            value.addValue(respTime, 1);
-                        } else {
-                            // We want to retain insertion order, so LinkedHashMap is necessary
-                            Map<Long, StatCalculatorLong> newSubList = new LinkedHashMap<>(5);
-                            StatCalculatorLong helper = new StatCalculatorLong();
-                            helper.addValue(Long.valueOf(sampleResult.getTime()),1);
-                            newSubList.put(startTimeIntervalLong,  helper);
-                            pList.put(sampleLabel, newSubList);
+                    }
+                    // List of value by sampler
+                    Map<Long, StatCalculatorLong> subList = pList.get(sampleLabel);
+                    final Long startTimeIntervalLong = Long.valueOf(startTimeInterval);
+                    if (subList != null) {
+                        long respTime = sampleResult.getTime();
+                        StatCalculatorLong value = subList.get(startTimeIntervalLong);
+                        if (value==null) {
+                            value = new StatCalculatorLong();
+                            subList.put(startTimeIntervalLong, value);
                         }
+                        value.addValue(respTime, 1);
+                    } else {
+                        // We want to retain insertion order, so LinkedHashMap is necessary
+                        Map<Long, StatCalculatorLong> newSubList = new LinkedHashMap<>(5);
+                        StatCalculatorLong helper = new StatCalculatorLong();
+                        helper.addValue(Long.valueOf(sampleResult.getTime()),1);
+                        newSubList.put(startTimeIntervalLong,  helper);
+                        pList.put(sampleLabel, newSubList);
                     }
                 }
             });
@@ -497,21 +493,17 @@ public class RespTimeGraphVisualizer extends AbstractVisualizer implements Actio
         tabbedGraph.addTab(JMeterUtils.getResString("aggregate_graph_tab_graph"), graphPanel); //$NON-NLS-1$
 
         // If clic on the Graph tab, make the graph (without apply interval or filter)
-        ChangeListener changeListener = new ChangeListener() {
-            @Override
-            public void stateChanged(ChangeEvent changeEvent) {
-                JTabbedPane srcTab = (JTabbedPane) changeEvent.getSource();
-                int index = srcTab.getSelectedIndex();
-                if (srcTab.getTitleAt(index).equals(JMeterUtils.getResString("aggregate_graph_tab_graph"))) { //$NON-NLS-1$
-                    actionMakeGraph();
-                }
+        ChangeListener changeListener = changeEvent -> {
+            JTabbedPane srcTab = (JTabbedPane) changeEvent.getSource();
+            int index = srcTab.getSelectedIndex();
+            if (srcTab.getTitleAt(index).equals(JMeterUtils.getResString("aggregate_graph_tab_graph"))) { //$NON-NLS-1$
+                actionMakeGraph();
             }
         };
         tabbedGraph.addChangeListener(changeListener);
 
         this.add(mainPanel, BorderLayout.NORTH);
         this.add(tabbedGraph, BorderLayout.CENTER);
-
     }
 
     @Override
diff --git a/src/components/src/test/java/org/apache/jmeter/timers/poissonarrivals/PreciseThroughputTimerTest.java b/src/components/src/test/java/org/apache/jmeter/timers/poissonarrivals/PreciseThroughputTimerTest.java
index 3740134..73bd696 100644
--- a/src/components/src/test/java/org/apache/jmeter/timers/poissonarrivals/PreciseThroughputTimerTest.java
+++ b/src/components/src/test/java/org/apache/jmeter/timers/poissonarrivals/PreciseThroughputTimerTest.java
@@ -68,20 +68,10 @@ public class PreciseThroughputTimerTest {
     protected ConstantPoissonProcessGenerator getConstantPoissonProcessGenerator(
             final double throughput, final int duration, long seed) {
         return new ConstantPoissonProcessGenerator(
-                new ThroughputProvider() {
-                    @Override
-                    public double getThroughput() {
-                        return throughput; // samples per second
-                    }
-                },
+                () -> throughput, // samples per second
                 1,
                 0,
-                new DurationProvider() {
-                    @Override
-                    public long getDuration() {
-                        return duration; // "expected" test duration: 3 seconds
-                    }
-                },
+                () -> duration, // "expected" test duration: 3 seconds
                 10000,
                 0.1,
                 seed, // Seed
diff --git a/src/core/src/main/java/org/apache/jmeter/gui/tree/JMeterTreeTransferHandler.java b/src/core/src/main/java/org/apache/jmeter/gui/tree/JMeterTreeTransferHandler.java
index ef902d6..e103647 100644
--- a/src/core/src/main/java/org/apache/jmeter/gui/tree/JMeterTreeTransferHandler.java
+++ b/src/core/src/main/java/org/apache/jmeter/gui/tree/JMeterTreeTransferHandler.java
@@ -61,13 +61,11 @@ public class JMeterTreeTransferHandler extends TransferHandler {
         }
     }
 
-
     @Override
     public int getSourceActions(JComponent c) {
         return MOVE;
     }
 
-
     @Override
     protected Transferable createTransferable(JComponent c) {
         this.nodesForRemoval = null;
@@ -107,23 +105,17 @@ public class JMeterTreeTransferHandler extends TransferHandler {
         return null;
     }
 
-
     private static void sortTreePathByRow(TreePath[] paths, final JTree tree) {
-        Comparator<TreePath> cp = new Comparator<TreePath>() {
+        Comparator<TreePath> cp = (o1, o2) -> {
+            int row1 = tree.getRowForPath(o1);
+            int row2 = tree.getRowForPath(o2);
 
-            @Override
-            public int compare(TreePath o1, TreePath o2) {
-                int row1 = tree.getRowForPath(o1);
-                int row2 = tree.getRowForPath(o2);
-
-                return row1<row2 ? -1 : (row1==row2 ? 0 : 1);
-            }
+            return Integer.compare(row1, row2);
         };
 
         Arrays.sort(paths, cp);
     }
 
-
     @Override
     protected void exportDone(JComponent source, Transferable data, int action) {
 
@@ -198,7 +190,6 @@ public class JMeterTreeTransferHandler extends TransferHandler {
         return MenuFactory.canAddTo(target, nodes);
     }
 
-
     @Override
     public boolean importData(TransferHandler.TransferSupport support) {
         if (!canImport(support)) {
@@ -275,7 +266,6 @@ public class JMeterTreeTransferHandler extends TransferHandler {
         return true;
     }
 
-
     private JMeterTreeNode[] getDraggedNodes(Transferable t) {
         JMeterTreeNode[] nodes = null;
         try {
@@ -287,7 +277,6 @@ public class JMeterTreeTransferHandler extends TransferHandler {
         return nodes;
     }
 
-
     private class NodesTransferable implements Transferable {
         JMeterTreeNode[] nodes;
 
diff --git a/src/core/src/main/java/org/apache/jmeter/report/core/Converters.java b/src/core/src/main/java/org/apache/jmeter/report/core/Converters.java
index 7bd09ae..96a8b7a 100644
--- a/src/core/src/main/java/org/apache/jmeter/report/core/Converters.java
+++ b/src/core/src/main/java/org/apache/jmeter/report/core/Converters.java
@@ -33,75 +33,51 @@ public final class Converters {
 
     static {
 
-        StringConverter<Character> characterConverter = new StringConverter<Character>() {
-
-            @Override
-            public Character convert(String value) throws ConvertException {
-                try {
-                    return Character.valueOf(value.charAt(0));
-                } catch (NumberFormatException ex) {
-                    throw new ConvertException(value, Character.class.getName(),
-                            ex);
-                }
+        StringConverter<Character> characterConverter = value -> {
+            try {
+                return Character.valueOf(value.charAt(0));
+            } catch (NumberFormatException ex) {
+                throw new ConvertException(value, Character.class.getName(), ex);
             }
         };
         CONVERTER_MAP.put(Character.class, characterConverter);
         CONVERTER_MAP.put(char.class, characterConverter);
 
-        StringConverter<Double> doubleConverter = new StringConverter<Double>() {
-
-            @Override
-            public Double convert(String value) throws ConvertException {
-                try {
-                    return Double.valueOf(value);
-                } catch (NumberFormatException ex) {
-                    throw new ConvertException(value, Double.class.getName(),
-                            ex);
-                }
+        StringConverter<Double> doubleConverter = value -> {
+            try {
+                return Double.valueOf(value);
+            } catch (NumberFormatException ex) {
+                throw new ConvertException(value, Double.class.getName(), ex);
             }
         };
         CONVERTER_MAP.put(Double.class, doubleConverter);
         CONVERTER_MAP.put(double.class, doubleConverter);
 
-        StringConverter<Float> floatConverter = new StringConverter<Float>() {
-
-            @Override
-            public Float convert(String value) throws ConvertException {
-                try {
-                    return Float.valueOf(value);
-                } catch (NumberFormatException ex) {
-                    throw new ConvertException(value, Float.class.getName(),
-                            ex);
-                }
+        StringConverter<Float> floatConverter = value -> {
+            try {
+                return Float.valueOf(value);
+            } catch (NumberFormatException ex) {
+                throw new ConvertException(value, Float.class.getName(), ex);
             }
         };
         CONVERTER_MAP.put(Float.class, floatConverter);
         CONVERTER_MAP.put(float.class, floatConverter);
 
-        StringConverter<Integer> integerConverter = new StringConverter<Integer>() {
-
-            @Override
-            public Integer convert(String value) throws ConvertException {
-                try {
-                    return Integer.valueOf(value.trim());
-                } catch (NumberFormatException ex) {
-                    throw new ConvertException(value, Integer.class.getName(),
-                            ex);
-                }
+        StringConverter<Integer> integerConverter = value -> {
+            try {
+                return Integer.valueOf(value.trim());
+            } catch (NumberFormatException ex) {
+                throw new ConvertException(value, Integer.class.getName(), ex);
             }
         };
         CONVERTER_MAP.put(Integer.class, integerConverter);
         CONVERTER_MAP.put(int.class, integerConverter);
 
-        StringConverter<Long> longConverter = new StringConverter<Long>() {
-
-            @Override
-            public Long convert(String value) throws ConvertException {
-                try {
-                    return Long.valueOf(value.trim());
-                } catch (NumberFormatException ex) {
-                    throw new ConvertException(value, Long.class.getName(), ex);
-                }
+        StringConverter<Long> longConverter = value -> {
+            try {
+                return Long.valueOf(value.trim());
+            } catch (NumberFormatException ex) {
+                throw new ConvertException(value, Long.class.getName(), ex);
             }
         };
         CONVERTER_MAP.put(Long.class, longConverter);
@@ -112,13 +88,7 @@ public final class Converters {
         CONVERTER_MAP.put(Boolean.class, booleanConverter);
         CONVERTER_MAP.put(boolean.class, booleanConverter);
 
-        CONVERTER_MAP.put(File.class, new StringConverter<File>() {
-
-            @Override
-            public File convert(String value) throws ConvertException {
-                return new File(value);
-            }
-        });
+        CONVERTER_MAP.put(File.class, (StringConverter<File>) File::new);
     }
 
     private Converters() {
@@ -128,10 +98,8 @@ public final class Converters {
     /**
      * Gets the converter for the specified class.
      *
-     * @param <T>
-     *            the target type
-     * @param clazz
-     *            the target class
+     * @param <T>   the target type
+     * @param clazz the target class
      * @return the converter
      */
     @SuppressWarnings("unchecked")
@@ -143,15 +111,11 @@ public final class Converters {
     /**
      * Converts the specified value to the destination type
      *
-     * @param <T>
-     *            the target type
-     * @param clazz
-     *            the target class
-     * @param value
-     *            the value to convert
+     * @param <T>   the target type
+     * @param clazz the target class
+     * @param value the value to convert
      * @return the converted value
-     * @throws ConvertException
-     *             when the conversion failed
+     * @throws ConvertException when the conversion failed
      */
     public static <T> T convert(Class<T> clazz, String value)
             throws ConvertException {
diff --git a/src/core/src/main/java/org/apache/jmeter/swing/HtmlPane.java b/src/core/src/main/java/org/apache/jmeter/swing/HtmlPane.java
index 40ce654..42f9090 100644
--- a/src/core/src/main/java/org/apache/jmeter/swing/HtmlPane.java
+++ b/src/core/src/main/java/org/apache/jmeter/swing/HtmlPane.java
@@ -22,7 +22,6 @@ import java.awt.Rectangle;
 
 import javax.swing.JTextPane;
 import javax.swing.event.HyperlinkEvent;
-import javax.swing.event.HyperlinkListener;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -36,19 +35,17 @@ public class HtmlPane extends JTextPane {
     private static final Logger log = LoggerFactory.getLogger(HtmlPane.class);
 
     public HtmlPane() {
-        this.addHyperlinkListener(new HyperlinkListener() {
-            @Override
-            public void hyperlinkUpdate(HyperlinkEvent e) {
-                if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
-                    String ref = e.getURL().getRef();
-                    if (ref != null) {
-                        log.debug("reference to scroll to = '{}'", ref);
-                        if (ref.length() > 0) {
-                            scrollToReference(ref);
-                        } else { // href="#"
-                            scrollRectToVisible(new Rectangle(1,1,1,1));
-                        }
-                    }
+        this.addHyperlinkListener(e -> {
+            if (e.getEventType() != HyperlinkEvent.EventType.ACTIVATED) {
+                return;
+            }
+            String ref = e.getURL().getRef();
+            if (ref != null) {
+                log.debug("reference to scroll to = '{}'", ref);
+                if (ref.length() > 0) {
+                    scrollToReference(ref);
+                } else { // href="#"
+                    scrollRectToVisible(new Rectangle(1,1,1,1));
                 }
             }
         });
diff --git a/src/core/src/main/java/org/apache/jmeter/visualizers/gui/AbstractVisualizer.java b/src/core/src/main/java/org/apache/jmeter/visualizers/gui/AbstractVisualizer.java
index 3aa0e72..2e7770b 100644
--- a/src/core/src/main/java/org/apache/jmeter/visualizers/gui/AbstractVisualizer.java
+++ b/src/core/src/main/java/org/apache/jmeter/visualizers/gui/AbstractVisualizer.java
@@ -135,26 +135,20 @@ public abstract class AbstractVisualizer
             }
         });
         successOnlyLogging = new JCheckBox(JMeterUtils.getResString("log_success_only")); // $NON-NLS-1$
-        successOnlyLogging.addActionListener(new ActionListener(){
-            @Override
-            public void actionPerformed(ActionEvent e) {
-                if (successOnlyLogging.isSelected()) {
-                    errorLogging.setSelected(false);
-                }
+        successOnlyLogging.addActionListener(e -> {
+            if (successOnlyLogging.isSelected()) {
+                errorLogging.setSelected(false);
             }
         });
         JButton saveConfigButton = new JButton(JMeterUtils.getResString("config_save_settings")); // $NON-NLS-1$
-        saveConfigButton.addActionListener(new ActionListener() {
-            @Override
-            public void actionPerformed(ActionEvent e) {
-                SavePropertyDialog d = new SavePropertyDialog(
-                        GuiPackage.getInstance().getMainFrame(),
-                        JMeterUtils.getResString("sample_result_save_configuration"), // $NON-NLS-1$
-                        true, collector.getSaveConfig());
-                d.pack();
-                ComponentUtil.centerComponentInComponent(GuiPackage.getInstance().getMainFrame(), d);
-                d.setVisible(true);
-            }
+        saveConfigButton.addActionListener(e -> {
+            SavePropertyDialog d = new SavePropertyDialog(
+                    GuiPackage.getInstance().getMainFrame(),
+                    JMeterUtils.getResString("sample_result_save_configuration"), // $NON-NLS-1$
+                    true, collector.getSaveConfig());
+            d.pack();
+            ComponentUtil.centerComponentInComponent(GuiPackage.getInstance().getMainFrame(), d);
+            d.setVisible(true);
         });
 
         filePanel = new FilePanel(JMeterUtils.getResString("file_visualizer_output_file"), EXTS); // $NON-NLS-1$
@@ -163,7 +157,6 @@ public abstract class AbstractVisualizer
         filePanel.add(errorLogging);
         filePanel.add(successOnlyLogging);
         filePanel.add(saveConfigButton);
-
     }
 
     @Override
diff --git a/src/jorphan/src/main/java/org/apache/jorphan/gui/MenuScroller.java b/src/jorphan/src/main/java/org/apache/jorphan/gui/MenuScroller.java
index 192ce2b..e404f59 100644
--- a/src/jorphan/src/main/java/org/apache/jorphan/gui/MenuScroller.java
+++ b/src/jorphan/src/main/java/org/apache/jorphan/gui/MenuScroller.java
@@ -22,8 +22,6 @@ import java.awt.Color;
 import java.awt.Component;
 import java.awt.Dimension;
 import java.awt.Graphics;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
 import java.awt.event.MouseWheelEvent;
 import java.awt.event.MouseWheelListener;
 
@@ -623,13 +621,9 @@ public class MenuScroller {
         private static final long serialVersionUID = 1;
 
         public MenuScrollTimer(final int increment, int interval) {
-            super(interval, new ActionListener() {
-
-                @Override
-                public void actionPerformed(ActionEvent e) {
-                    firstIndex += increment;
-                    refreshMenu();
-                }
+            super(interval, e -> {
+                firstIndex += increment;
+                refreshMenu();
             });
         }
     }
diff --git a/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java b/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
index 0b158d7..fc84fab 100644
--- a/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
+++ b/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
@@ -21,7 +21,6 @@ package org.apache.jmeter.protocol.http.sampler;
 import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.IOException;
-import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.UnsupportedEncodingException;
 import java.net.InetAddress;
@@ -199,27 +198,13 @@ public class HTTPHC4Impl extends HTTPHCAbstractImpl {
 
     private static final Logger log = LoggerFactory.getLogger(HTTPHC4Impl.class);
 
-    private static final InputStreamFactory GZIP = new InputStreamFactory() {
-        @Override
-        public InputStream create(final InputStream instream) throws IOException {
-            return new LaxGZIPInputStream(instream, GZIP_RELAX_MODE);
-        }
-    };
+    private static final InputStreamFactory GZIP =
+            instream -> new LaxGZIPInputStream(instream, GZIP_RELAX_MODE);
 
-    private static final InputStreamFactory DEFLATE = new InputStreamFactory() {
-        @Override
-        public InputStream create(final InputStream instream) throws IOException {
-            return new LaxDeflateInputStream(instream, DEFLATE_RELAX_MODE);
-        }
+    private static final InputStreamFactory DEFLATE =
+            instream -> new LaxDeflateInputStream(instream, DEFLATE_RELAX_MODE);
 
-    };
-
-    private static final InputStreamFactory BROTLI = new InputStreamFactory() {
-        @Override
-        public InputStream create(final InputStream instream) throws IOException {
-            return new BrotliInputStream(instream);
-        }
-    };
+    private static final InputStreamFactory BROTLI = BrotliInputStream::new;
 
     private static final class PreemptiveAuthRequestInterceptor implements HttpRequestInterceptor {
         @Override
@@ -382,11 +367,8 @@ public class HTTPHC4Impl extends HTTPHCAbstractImpl {
     };
 
     private static final String DIGEST_PARAMETERS = DigestParameters.VARIABLE_NAME;
-
-
     private static final HttpRequestInterceptor PREEMPTIVE_AUTH_INTERCEPTOR = new PreemptiveAuthRequestInterceptor();
 
-
     // see  https://stackoverflow.com/questions/26166469/measure-bandwidth-usage-with-apache-httpcomponents-httpclient
     private static final HttpRequestExecutor REQUEST_EXECUTOR = new HttpRequestExecutor() {
         @Override
@@ -406,9 +388,6 @@ public class HTTPHC4Impl extends HTTPHCAbstractImpl {
         }
     };
 
-    /**
-     * Headers to save
-     */
     private static final String[] HEADERS_TO_SAVE = new String[]{
                     "content-length",
                     "content-encoding",
@@ -809,16 +788,11 @@ public class HTTPHC4Impl extends HTTPHCAbstractImpl {
      * Setup Body of request if different from GET.
      * Field HTTPSampleResult#queryString of result is modified in the 2 cases
      *
-     * @param method
-     *            String HTTP method
-     * @param result
-     *            {@link HTTPSampleResult}
-     * @param httpRequest
-     *            {@link HttpRequestBase}
-     * @param localContext
-     *            {@link HttpContext}
-     * @throws IOException
-     *             when posting data fails due to I/O
+     * @param method       String HTTP method
+     * @param result       {@link HTTPSampleResult}
+     * @param httpRequest  {@link HttpRequestBase}
+     * @param localContext {@link HttpContext}
+     * @throws IOException when posting data fails due to I/O
      */
     protected void handleMethod(String method, HTTPSampleResult result,
             HttpRequestBase httpRequest, HttpContext localContext) throws IOException {
@@ -1196,14 +1170,10 @@ public class HTTPHC4Impl extends HTTPHCAbstractImpl {
      * <li>Calls setConnectionCookie to setup Cookie</li>
      * </ul>
      *
-     * @param url
-     *            {@link URL} of the request
-     * @param httpRequest
-     *            http request for the request
-     * @param res
-     *            sample result to set cookies on
-     * @throws IOException
-     *             if hostname/ip to use could not be figured out
+     * @param url         {@link URL} of the request
+     * @param httpRequest http request for the request
+     * @param res         sample result to set cookies on
+     * @throws IOException if hostname/ip to use could not be figured out
      */
     protected void setupRequest(URL url, HttpRequestBase httpRequest, HTTPSampleResult res)
         throws IOException {
@@ -1266,8 +1236,7 @@ public class HTTPHC4Impl extends HTTPHCAbstractImpl {
     /**
      * Gets the ResponseHeaders
      *
-     * @param response
-     *            containing the headers
+     * @param response containing the headers
      * @return string containing the headers, one per line
      */
     private String getResponseHeaders(HttpResponse response) {
@@ -1326,14 +1295,11 @@ public class HTTPHC4Impl extends HTTPHCAbstractImpl {
      * Extracts all the required non-cookie headers for that particular URL request and
      * sets them in the <code>HttpMethod</code> passed in
      *
-     * @param request
-     *            <code>HttpRequest</code> which represents the request
-     * @param url
-     *            <code>URL</code> of the URL request
-     * @param headerManager
-     *            the <code>HeaderManager</code> containing all the cookies
-     *            for this <code>UrlConfig</code>
-     * @param cacheManager the CacheManager (may be null)
+     * @param request       <code>HttpRequest</code> which represents the request
+     * @param url           <code>URL</code> of the URL request
+     * @param headerManager the <code>HeaderManager</code> containing all the cookies
+     *                      for this <code>UrlConfig</code>
+     * @param cacheManager  the CacheManager (may be null)
      */
     protected void setConnectionHeaders(HttpRequestBase request, URL url, HeaderManager headerManager, CacheManager cacheManager) {
         if (headerManager != null) {
@@ -1375,11 +1341,9 @@ public class HTTPHC4Impl extends HTTPHCAbstractImpl {
      * Get port from the value of the Host header, or return the given
      * defaultValue
      *
-     * @param hostHeaderValue
-     *            value of the http Host header
-     * @param defaultValue
-     *            value to be used, when no port could be extracted from
-     *            hostHeaderValue
+     * @param hostHeaderValue value of the http Host header
+     * @param defaultValue    value to be used, when no port could be extracted from
+     *                        hostHeaderValue
      * @return integer representing the port for the host header
      */
     private int getPortFromHostHeader(String hostHeaderValue, int defaultValue) {
@@ -1396,8 +1360,7 @@ public class HTTPHC4Impl extends HTTPHCAbstractImpl {
     /**
      * Get all the request headers except Cookie for the <code>HttpRequest</code>
      *
-     * @param method
-     *            <code>HttpMethod</code> which represents the request
+     * @param method <code>HttpMethod</code> which represents the request
      * @return the headers as a string
      */
     private String getAllHeadersExceptCookie(HttpRequest method) {
@@ -1407,8 +1370,7 @@ public class HTTPHC4Impl extends HTTPHCAbstractImpl {
     /**
      * Get only Cookie header for the <code>HttpRequest</code>
      *
-     * @param method
-     *            <code>HttpMethod</code> which represents the request
+     * @param method <code>HttpMethod</code> which represents the request
      * @return the headers as a string
      */
     private String getOnlyCookieFromHeaders(HttpRequest method) {
@@ -1423,8 +1385,7 @@ public class HTTPHC4Impl extends HTTPHCAbstractImpl {
     /**
      * Get only cookies from request headers for the <code>HttpRequest</code>
      *
-     * @param method
-     *            <code>HttpMethod</code> which represents the request
+     * @param method <code>HttpMethod</code> which represents the request
      * @return the headers as a string
      */
     private String getFromHeadersMatchingPredicate(HttpRequest method, Predicate<String> predicate) {
@@ -1756,7 +1717,6 @@ public class HTTPHC4Impl extends HTTPHCAbstractImpl {
 
 
     /**
-     *
      * @return the value of {@link #getContentEncoding()}; forced to null if empty
      */
     private String getContentEncodingOrNull() {
@@ -1809,9 +1769,6 @@ public class HTTPHC4Impl extends HTTPHCAbstractImpl {
         closeThreadLocalConnections();
     }
 
-    /**
-     *
-     */
     private void closeThreadLocalConnections() {
         // Does not need to be synchronised, as all access is from same thread
         Map<HttpClientKey, MutableTriple<CloseableHttpClient, AuthState, PoolingHttpClientConnectionManager>>
diff --git a/src/protocol/junit/src/main/java/org/apache/jmeter/protocol/java/sampler/JUnitSampler.java b/src/protocol/junit/src/main/java/org/apache/jmeter/protocol/java/sampler/JUnitSampler.java
index 190947b..dba1fad 100644
--- a/src/protocol/junit/src/main/java/org/apache/jmeter/protocol/java/sampler/JUnitSampler.java
+++ b/src/protocol/junit/src/main/java/org/apache/jmeter/protocol/java/sampler/JUnitSampler.java
@@ -670,32 +670,24 @@ public class JUnitSampler extends AbstractSampler implements ThreadListener {
                 }
                 final AnnotatedTestCase at = new AnnotatedTestCase(m, expectedException, timeout);
                 testCase = at;
-                protectable = new Protectable() {
-                    @Override
-                    public void protect() throws Throwable {
-                        at.runTest();
-                    }
-                };
+                protectable = at::runTest;
             } else {
                 this.testCase = (TestCase) this.testObject;
                 final Object theClazz = this.testObject; // Must be final to create instance
-                protectable = new Protectable() {
-                    @Override
-                    public void protect() throws Throwable {
-                        try {
-                            m.invoke(theClazz,new Object[0]);
-                        } catch (InvocationTargetException e) {
-                            /*
-                             * Calling a method via reflection results in wrapping any
-                             * Exceptions in ITE; unwrap these here so runProtected can
-                             * allocate them correctly.
-                             */
-                            Throwable t = e.getCause();
-                            if (t != null) {
-                                throw t;
-                            }
-                            throw e;
+                protectable = () -> {
+                    try {
+                        m.invoke(theClazz, new Object[0]);
+                    } catch (InvocationTargetException e) {
+                        /*
+                         * Calling a method via reflection results in wrapping any
+                         * Exceptions in ITE; unwrap these here so runProtected can
+                         * allocate them correctly.
+                         */
+                        Throwable t = e.getCause();
+                        if (t != null) {
+                            throw t;
                         }
+                        throw e;
                     }
                 };
             }