mirror of https://github.com/apache/jmeter.git
Part of 62637 Avoid Integer overrun when dealing with very large values in TimerService#adjustDelay
Bugzilla 62637
git-svn-id: https://svn.apache.org/repos/asf/jmeter/trunk@1838646 13f79535-47bb-0310-9956-ffa450edef68
Former-commit-id: 3d03af3d78
This commit is contained in:
parent
4025c36d5d
commit
80c06fe50e
|
|
@ -65,7 +65,7 @@ public class TimerService {
|
|||
public long adjustDelay(final long initialDelay, long endTime) {
|
||||
if (endTime > 0) {
|
||||
long now = System.currentTimeMillis();
|
||||
if(now + initialDelay > endTime) {
|
||||
if (initialDelay > endTime - now) {
|
||||
return endTime - now;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.apache.jmeter.timers;
|
||||
|
||||
import org.hamcrest.CoreMatchers;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TimerServiceTest {
|
||||
|
||||
TimerService sut = TimerService.getInstance();
|
||||
|
||||
@Test
|
||||
public void testBigInitialDelay() {
|
||||
long now = System.currentTimeMillis();
|
||||
long adjustedDelay = sut.adjustDelay(Long.MAX_VALUE, now + 1000L);
|
||||
// As #adjustDelay uses System#currentTimeMillis we can't be sure, that the value is exact 1000L
|
||||
Assert.assertThat(Math.abs(adjustedDelay - 1000L) < 150L, CoreMatchers.is(true));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -267,6 +267,7 @@ this behaviour, set <code>httpclient.reset_state_on_thread_group_iteration=false
|
|||
<li><bug>62478</bug>Escape commata in parameters when constructing function strings in the GUI function helper. Reported by blue414 (blue414 at 163.com)</li>
|
||||
<li><bug>62463</bug>Fix usage of ports, when <code>client.rmi.localport</code> is set for distributed runs.</li>
|
||||
<li><bug>62545</bug>Don't use a colon as part of the "tab" string when indenting JSON in RenderAsJSON.</li>
|
||||
<li>Part of <bug>62637</bug> Avoid Integer overrun when dealing with very large values in <code>TimerService#adjustDelay</code></li>
|
||||
</ul>
|
||||
|
||||
<!-- =================== Thanks =================== -->
|
||||
|
|
|
|||
Loading…
Reference in New Issue