Skip to content
This repository was archived by the owner on Nov 24, 2025. It is now read-only.
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- [#7120](https://github.com/apache/trafficcontrol/pull/7120) *Docs* Update t3c documentation regarding parent.config parent_retry.

### Fixed
- [#7252](https://github.com/apache/trafficcontrol/issues/7252) *Traffic Router* Fixed integer overflow for `czCount`, by resetting the count to max value when it overflows.
- [#7221](https://github.com/apache/trafficcontrol/issues/7221) *Docs* Fixed request structure spec in cdn locks description in APIv4.
- [#7225](https://github.com/apache/trafficcontrol/issues/7225) *Docs* Fixed docs for /roles response description in APIv4.
- [#7246](https://github.com/apache/trafficcontrol/issues/7246) *Docs* Fixed docs for /jobs response description in APIv4 and APIv5.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ public class StatTracker {

public static class Tallies {

public int getCzCount() {
public long getCzCount() {
return czCount;
}
public void setCzCount(final int czCount) {
public void setCzCount(final long czCount) {
this.czCount = czCount;
}
public int getGeoCount() {
Expand Down Expand Up @@ -97,7 +97,7 @@ public void setRegionalAlternateCount(final int regionalAlternateCount) {
this.regionalAlternateCount = regionalAlternateCount;
}

public int czCount;
public long czCount;
public int geoCount;
public int deepCzCount;
public int missCount;
Expand Down Expand Up @@ -373,7 +373,7 @@ public void saveTrack(final Track t) {
totalDnsCount++;
totalDnsTime += t.time;
}
map = dnsMap;
map = getDnsMap();

if (t.resultDetails == Track.ResultDetails.LOCALIZED_DNS) {
return;
Expand All @@ -387,7 +387,7 @@ public void saveTrack(final Track t) {
totalHttpCount++;
totalHttpTime += t.time;
}
map = httpMap;
map = getHttpMap();
}
map.putIfAbsent(fqdn, new Tallies());
incTally(t, map.get(fqdn));
Expand All @@ -402,6 +402,9 @@ private static void incTally(final Track t, final Tallies tallies) {
break;
case CZ:
tallies.czCount++;
if (tallies.czCount < 0) {
tallies.czCount = Long.MAX_VALUE;
}
break;
case GEO:
tallies.geoCount++;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
*
* Licensed 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.traffic_control.traffic_router.core.router;

import org.junit.Test;
import java.util.HashMap;
import java.util.Map;
import static org.powermock.api.mockito.PowerMockito.spy;
import static org.powermock.api.mockito.PowerMockito.when;
import static org.springframework.test.util.AssertionErrors.assertEquals;

public class StatTrackerTest {
@Test
public void testIncTally() {
StatTracker tracker = spy(new StatTracker());
StatTracker.Tallies tallies = new StatTracker.Tallies();
StatTracker.Track track = StatTracker.getTrack();

tallies.setCzCount(Long.MAX_VALUE);

Map<String, StatTracker.Tallies> map = new HashMap<>();
map.put("blah", tallies);
when(tracker.getDnsMap()).thenReturn(map);

track.setRouteType(StatTracker.Track.RouteType.DNS, "blah");
track.setResult(StatTracker.Track.ResultType.CZ);
tracker.saveTrack(track);
assertEquals("expected czCount to be max long value but got " + tallies.getCzCount(), Long.MAX_VALUE, tallies.getCzCount());
}
}