Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unnecessary boxing #541

Merged
merged 2 commits into from
Nov 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public CompareAssertionBeanInfo() {
p.setValue(NOT_EXPRESSION, Boolean.TRUE);
p = property("compareTime"); //$NON-NLS-1$
p.setValue(NOT_UNDEFINED, Boolean.TRUE);
p.setValue(DEFAULT, Long.valueOf(-1));
p.setValue(DEFAULT, -1L);
p.setValue(NOT_EXPRESSION, Boolean.FALSE);
p = property("stringsToSkip"); //$NON-NLS-1$
p.setPropertyEditorClass(TableEditor.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public AssertionResult getResult(SampleResult response) {
// has the Sample lasted too long?
if ( responseTime > duration ) {
result.setFailure(true);
Object[] arguments = { Long.valueOf(responseTime), Long.valueOf(duration) };
Object[] arguments = {responseTime, duration};
String message = MessageFormat.format(
JMeterUtils.getResString("duration_assertion_failure") // $NON-NLS-1$
, arguments);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public AssertionResult getResult(SampleResult response) {
final String msg = compareSize(resultSize);
if (msg.length() > 0) {
result.setFailure(true);
Object[] arguments = { Long.valueOf(resultSize), msg, Long.valueOf(getAllowedSize()) };
Object[] arguments = {resultSize, msg, Long.valueOf(getAllowedSize()) };
String message = MessageFormat.format(
JMeterUtils.getResString("size_assertion_failure"), arguments); //$NON-NLS-1$
result.setFailureMessage(message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ private Random createRandom() {
if (randomSeed.length()>0){
Long seed = getRandomSeedAsLong();
if(seed != null) {
return new Random(seed.longValue());
return new Random(seed);
}
}
return new Random();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ private String generateResult(MatchResult match) {
log.debug("RegexExtractor: Template piece {} ({})", obj, obj.getClass());
}
if (obj instanceof Integer) {
result.append(match.group(((Integer) obj).intValue()));
result.append(match.group((Integer) obj));
} else {
result.append(obj);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ private void handleListResult(JMeterVariables vars, String refName, String defau
if (log.isDebugEnabled()) {
log.debug(
"matchNumber({}) exceeds number of items found({}), default value will be used",
Integer.valueOf(matchNumber), Integer.valueOf(resultList.size()));
matchNumber, resultList.size());
}
vars.put(refName, defaultValue);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ private void handleListResult(JMeterVariables vars, String[] defaultValues, fina
if(log.isDebugEnabled()) {
log.debug(
"matchNumber({}) exceeds number of items found({}), default value will be used",
Integer.valueOf(matchNumber), Integer.valueOf(extractedValues.size()));
matchNumber, extractedValues.size());
}
vars.put(currentRefName, defaultValues[i]);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public class CounterConfig extends AbstractTestElement
private static final Logger log = LoggerFactory.getLogger(CounterConfig.class);

private void init() { // WARNING: called from ctor so must not be overridden (i.e. must be private or final)
perTheadNumber = ThreadLocal.withInitial(()-> Long.valueOf(getStart()));
perTheadNumber = ThreadLocal.withInitial(this::getStart);
perTheadLastIterationNumber = ThreadLocal.withInitial(() -> Long.valueOf(1));
}

Expand Down Expand Up @@ -102,22 +102,22 @@ public void iterationStart(LoopIterationEvent event) {
globalCounter += increment;
}
} else {
long current = perTheadNumber.get().longValue();
long current = perTheadNumber.get();
if(isResetOnThreadGroupIteration()) {
int iteration = variables.getIteration();
Long lastIterationNumber = perTheadLastIterationNumber.get();
if(iteration != lastIterationNumber.longValue()) {
if(iteration != lastIterationNumber) {
// reset
current = getStart();
}
perTheadLastIterationNumber.set(Long.valueOf(iteration));
perTheadLastIterationNumber.set((long) iteration);
}
variables.put(getVarName(), formatNumber(current));
current += increment;
if (current > end) {
current = start;
}
perTheadNumber.set(Long.valueOf(current));
perTheadNumber.set(current);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ private void pause(String timeInMillis) {
long adjustDelay = TIMER_SERVICE.adjustDelay(millis);
if (log.isDebugEnabled()) {
log.debug("Sleeping in Flow Control Action for {} ms (asked for {} ms)",
Long.valueOf(adjustDelay),
Long.valueOf(millis));
adjustDelay,
millis);
}
TimeUnit.MILLISECONDS.sleep(adjustDelay);
} else if (millis < 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public long delay() {
}
}
try {
return Long.decode(ret).longValue();
return Long.decode(ret);
} catch (NumberFormatException e){
log.warn("Number format exception while decoding number: '{}'", ret);
return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ public ConstantThroughputTimerBeanInfo() {

PropertyDescriptor p = property("throughput"); //$NON-NLS-1$
p.setValue(NOT_UNDEFINED, Boolean.TRUE);
p.setValue(DEFAULT, Double.valueOf(0.0));
p.setValue(DEFAULT, 0.0);

p = property("calcMode", ConstantThroughputTimer.Mode.class); //$NON-NLS-1$
p.setValue(DEFAULT, Integer.valueOf(ConstantThroughputTimer.Mode.ThisThreadOnly.ordinal()));
p.setValue(DEFAULT, ConstantThroughputTimer.Mode.ThisThreadOnly.ordinal());
p.setValue(NOT_UNDEFINED, Boolean.TRUE); // must be defined
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ public SyncTimerBeanInfo() {

PropertyDescriptor p = property("groupSize");
p.setValue(NOT_UNDEFINED, Boolean.TRUE);
p.setValue(DEFAULT, Integer.valueOf(0));
p.setValue(DEFAULT, 0);

p = property("timeoutInMs");
p.setValue(NOT_UNDEFINED, Boolean.TRUE);
p.setValue(DEFAULT, Long.valueOf(0));
p.setValue(DEFAULT, 0L);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ public PreciseThroughputTimerBeanInfo() {
PropertyDescriptor p;
p = property("throughput"); //$NON-NLS-1$
p.setValue(NOT_UNDEFINED, Boolean.TRUE);
p.setValue(DEFAULT, Double.valueOf(100));
p.setValue(DEFAULT, 100d);

p = property("throughputPeriod"); //$NON-NLS-1$
p.setValue(NOT_UNDEFINED, Boolean.TRUE);
p.setValue(DEFAULT, 3600);

p = property("duration"); //$NON-NLS-1$
p.setValue(NOT_UNDEFINED, Boolean.TRUE);
p.setValue(DEFAULT, Long.valueOf(3600));
p.setValue(DEFAULT, 3600L);

createPropertyGroup(
"batching", //$NON-NLS-1$
Expand Down Expand Up @@ -77,11 +77,11 @@ public PreciseThroughputTimerBeanInfo() {

p = property("exactLimit"); //$NON-NLS-1$
p.setValue(NOT_UNDEFINED, Boolean.TRUE);
p.setValue(DEFAULT, Integer.valueOf(10000));
p.setValue(DEFAULT, 10000);

p = property("allowedThroughputSurplus"); //$NON-NLS-1$
p.setValue(NOT_UNDEFINED, Boolean.TRUE);
p.setValue(DEFAULT, Double.valueOf(1.0d));
p.setValue(DEFAULT, 1.0d);

createPropertyGroup(
"repeatability", //$NON-NLS-1$
Expand All @@ -92,6 +92,6 @@ public PreciseThroughputTimerBeanInfo() {

p = property("randomSeed"); //$NON-NLS-1$
p.setValue(NOT_UNDEFINED, Boolean.TRUE);
p.setValue(DEFAULT, Long.valueOf(0));
p.setValue(DEFAULT, 0L);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ public void add(final SampleResult sampleResult) {
}
// List of value by sampler
Map<Long, StatCalculatorLong> subList = pList.get(sampleLabel);
final Long startTimeIntervalLong = Long.valueOf(startTimeInterval);
final Long startTimeIntervalLong = startTimeInterval;
if (subList != null) {
long respTime = sampleResult.getTime();
StatCalculatorLong value = subList.get(startTimeIntervalLong);
Expand Down Expand Up @@ -372,15 +372,15 @@ public void makeGraph() {
graphPanel.setColor(getLinesColors());
graphPanel.setShowGrouping(numberShowGrouping.isSelected());
graphPanel.setLegendPlacement(StatGraphProperties.getPlacementNameMap()
.get(legendPlacementList.getSelectedItem()).intValue());
.get(legendPlacementList.getSelectedItem()));
graphPanel.setPointShape(StatGraphProperties.getPointShapeMap().get(pointShapeLine.getSelectedItem()));
graphPanel.setStrokeWidth(Float.parseFloat((String) strokeWidthList.getSelectedItem()));

graphPanel.setTitleFont(new Font(StatGraphProperties.getFontNameMap().get(titleFontNameList.getSelectedItem()),
StatGraphProperties.getFontStyleMap().get(titleFontStyleList.getSelectedItem()).intValue(),
StatGraphProperties.getFontStyleMap().get(titleFontStyleList.getSelectedItem()),
Integer.parseInt((String) titleFontSizeList.getSelectedItem())));
graphPanel.setLegendFont(new Font(StatGraphProperties.getFontNameMap().get(fontNameList.getSelectedItem()),
StatGraphProperties.getFontStyleMap().get(fontStyleList.getSelectedItem()).intValue(),
StatGraphProperties.getFontStyleMap().get(fontStyleList.getSelectedItem()),
Integer.parseInt((String) fontSizeList.getSelectedItem())));

graphPanel.setHeight(height);
Expand Down Expand Up @@ -408,7 +408,7 @@ public double[][] getData() {
int idx = 0;
while (idx < durationTest) {
long keyShift = minStartTime + idx;
StatCalculatorLong value = subList.get(Long.valueOf(keyShift));
StatCalculatorLong value = subList.get(keyShift);
if (value != null) {
nanLast = value.getMean();
data[s][idx] = nanLast;
Expand All @@ -427,7 +427,7 @@ public double[][] getData() {
nanList.clear();
}
} else {
nanList.add(Double.valueOf(Double.NaN));
nanList.add(Double.NaN);
nanBegin = nanLast;
data[s][idx] = Double.NaN;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ public class StatGraphVisualizer extends AbstractVisualizer implements Clearable
private static final String PCT2_LABEL = JMeterUtils.getPropDefault("aggregate_rpt_pct2", "95");
private static final String PCT3_LABEL = JMeterUtils.getPropDefault("aggregate_rpt_pct3", "99");

private static final Float PCT1_VALUE = Float.valueOf(Float.parseFloat(PCT1_LABEL)/100);
private static final Float PCT2_VALUE = Float.valueOf(Float.parseFloat(PCT2_LABEL)/100);
private static final Float PCT3_VALUE = Float.valueOf(Float.parseFloat(PCT3_LABEL)/100);
private static final Float PCT1_VALUE = Float.parseFloat(PCT1_LABEL) / 100;
private static final Float PCT2_VALUE = Float.parseFloat(PCT2_LABEL) / 100;
private static final Float PCT3_VALUE = Float.parseFloat(PCT3_LABEL) / 100;

private static final Logger log = LoggerFactory.getLogger(StatGraphVisualizer.class);

Expand Down Expand Up @@ -623,16 +623,16 @@ public void makeGraph() {
graphPanel.setShowGrouping(numberShowGrouping.isSelected());
graphPanel.setValueOrientation(valueLabelsVertical.isSelected());
graphPanel.setLegendPlacement(StatGraphProperties.getPlacementNameMap()
.get(legendPlacementList.getSelectedItem()).intValue());
.get(legendPlacementList.getSelectedItem()));

graphPanel.setTitleFont(new Font(StatGraphProperties.getFontNameMap().get(titleFontNameList.getSelectedItem()),
StatGraphProperties.getFontStyleMap().get(titleFontStyleList.getSelectedItem()).intValue(),
StatGraphProperties.getFontStyleMap().get(titleFontStyleList.getSelectedItem()),
Integer.parseInt((String) titleFontSizeList.getSelectedItem())));
graphPanel.setLegendFont(new Font(StatGraphProperties.getFontNameMap().get(fontNameList.getSelectedItem()),
StatGraphProperties.getFontStyleMap().get(fontStyleList.getSelectedItem()).intValue(),
StatGraphProperties.getFontStyleMap().get(fontStyleList.getSelectedItem()),
Integer.parseInt((String) fontSizeList.getSelectedItem())));
graphPanel.setValueFont(new Font(StatGraphProperties.getFontNameMap().get(valueFontNameList.getSelectedItem()),
StatGraphProperties.getFontStyleMap().get(valueFontStyleList.getSelectedItem()).intValue(),
StatGraphProperties.getFontStyleMap().get(valueFontStyleList.getSelectedItem()),
Integer.parseInt((String) valueFontSizeList.getSelectedItem())));

graphPanel.setHeight(height);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ public Object invoke(Object pInvokee) {
Boolean success = (Boolean) super.invoke(pInvokee);

if (success != null) {
if (success.booleanValue()) {
if (success) {
return imageSuccess;
} else {
return imageFailure;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public long getLongParameter(String name, long defaultValue) {
}
final String valueString = params.get(name);
try {
return Long.decode(valueString).longValue();
return Long.decode(valueString);
} catch (NumberFormatException e) {
log.warn("Value for parameter '{}' not a long: '{}'. Using default: '{}'.", name, valueString,
defaultValue, e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ private void addMetrics(long timestampInSeconds, String contextName, SamplerMetr
for (Map.Entry<String, Float> entry : okPercentiles.entrySet()) {
graphiteMetricsManager.addMetric(timestampInSeconds, contextName,
entry.getKey(),
Double.toString(metric.getOkPercentile(entry.getValue().floatValue())));
Double.toString(metric.getOkPercentile(entry.getValue())));
}
}
if (metric.getFailures() > 0) {
Expand All @@ -240,7 +240,7 @@ private void addMetrics(long timestampInSeconds, String contextName, SamplerMetr
for (Map.Entry<String, Float> entry : koPercentiles.entrySet()) {
graphiteMetricsManager.addMetric(timestampInSeconds, contextName,
entry.getKey(),
Double.toString(metric.getKoPercentile(entry.getValue().floatValue())));
Double.toString(metric.getKoPercentile(entry.getValue())));
}
}
graphiteMetricsManager.addMetric(timestampInSeconds, contextName,
Expand All @@ -255,7 +255,7 @@ private void addMetrics(long timestampInSeconds, String contextName, SamplerMetr
for (Map.Entry<String, Float> entry : allPercentiles.entrySet()) {
graphiteMetricsManager.addMetric(timestampInSeconds, contextName,
entry.getKey(),
Double.toString(metric.getAllPercentile(entry.getValue().floatValue())));
Double.toString(metric.getAllPercentile(entry.getValue())));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ private void writeMetrics(List<MetricTuple> currentMetrics) {
// pw is not closed as it would close the underlying pooled out
PrintWriter pw = new PrintWriter(new OutputStreamWriter(out, CHARSET_NAME), false);
for (MetricTuple metric : currentMetrics) {
pw.printf("%s %s %d%n", metric.name, metric.value, Long.valueOf(metric.timestamp));
pw.printf("%s %s %d%n", metric.name, metric.value, metric.timestamp);
}
pw.flush();
if (log.isDebugEnabled()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ public void testBigInitialDelayAndDontWait() {
long now = System.currentTimeMillis();
long adjustedDelay = sut.adjustDelay(Long.MAX_VALUE, now + 1000L, false);
Assert.assertThat("TimerService should return -1 as delay would lead to a time after end time",
Long.valueOf(adjustedDelay), CoreMatchers.is(Long.valueOf(-1)));
adjustedDelay, CoreMatchers.is((long) -1));
}

@Test
public void testBigInitialDelayAndWait() {
long now = System.currentTimeMillis();
long adjustedDelay = sut.adjustDelay(Long.MAX_VALUE, now + 1000L);
Assert.assertThat("TimerService should return -1 as delay would lead to a time after end time",
Long.valueOf(adjustedDelay), isAlmost(1000L, 200L));
adjustedDelay, isAlmost(1000L, 200L));
}

private BaseMatcher<Long> isAlmost(long value, long precision) {
Expand All @@ -51,7 +51,7 @@ private BaseMatcher<Long> isAlmost(long value, long precision) {
public boolean matches(Object item) {
if (item instanceof Long) {
Long other = (Long) item;
return Math.abs(other.longValue() - value) < precision;
return Math.abs(other - value) < precision;
}
return false;
}
Expand All @@ -67,13 +67,13 @@ public void describeTo(Description description) {
public void testSmallInitialDelay() {
long now = System.currentTimeMillis();
Assert.assertThat("TimerService should not change the delay as the end time is far away",
Long.valueOf(sut.adjustDelay(1000L, now + 20000L)), CoreMatchers.is(Long.valueOf(1000L)));
sut.adjustDelay(1000L, now + 20000L), CoreMatchers.is(1000L));
}

@Test
public void testNegativeEndTime() {
Assert.assertThat("TimerService should not change the delay as the indicated end time is far away",
Long.valueOf(sut.adjustDelay(1000L, -1)), CoreMatchers.is(Long.valueOf(1000L)));
sut.adjustDelay(1000L, -1), CoreMatchers.is(1000L));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,19 @@ public int getLoops() {
// Evaluation occurs when nbLoops is not yet evaluated
// or when nbLoops is equal to special value INFINITE_LOOP_COUNT
if (nbLoops==null || // No evaluated yet
nbLoops.intValue()==0 || // Last iteration led to nbLoops == 0,
nbLoops ==0 || // Last iteration led to nbLoops == 0,
// in this case as resetLoopCount will not be called,
// it leads to no further evaluations if we don't evaluate, see BUG 56276
Comment on lines 85 to 86
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth fixing this indentation (or moving it to a form which doesn't require constant manual formatting?)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would probably be nice to use consistent spacing around == provided Spotless or something like that can auto-format the code.

Copy link
Contributor

@ham1 ham1 Oct 20, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I was referring to the block of // comments, but now you mention it, the spacing around == should at least be consistently wrong or correct ;)

Copy link
Collaborator Author

@vlsi vlsi Oct 20, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see. As discussed earlier, there's no point in maintaining horizontal alignment.
Frankly speaking, I don't like "line comments within expression", and it would probably look better if the comment is placed before if or if nbLoops ==0 was extracted to a separate method.

I'm not sure it makes sense to manually inspect this change and fix spacing around == because it would take time and it add no value.
I would rather spend the time on implementing Async HTTP client rather than dealing with spaces.

nbLoops.intValue()==INFINITE_LOOP_COUNT // Number of iteration is set to infinite
nbLoops ==INFINITE_LOOP_COUNT // Number of iteration is set to infinite
) {
try {
JMeterProperty prop = getProperty(LOOPS);
nbLoops = Integer.valueOf(prop.getStringValue());
} catch (NumberFormatException e) {
nbLoops = Integer.valueOf(0);
nbLoops = 0;
}
}
return nbLoops.intValue();
return nbLoops;
}

public String getLoopString() {
Expand Down
Loading