Skip to content
This repository was archived by the owner on Jul 14, 2026. It is now read-only.

Commit b0a618d

Browse files
kukvclaude
andcommitted
Fix review comments: apply coding guidelines and add missing tests
- Add @nullable to GlobalScheduleProperties.defaultTimezone() (L-1) - Update scheduleTimezone @PARAM Javadoc in EndpointGateEndpoint and ReactiveEndpointGateEndpoint to reflect fallback chain (M-1) - Update additional-spring-configuration-metadata.json gate-level timezone description to reflect global default fallback (M-2) - Add updateGate_usesDefaultScheduleTimezone and updateGate_usesExplicitTimezone tests to ReactiveEndpointGateEndpointTest (H-1) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent e7941ed commit b0a618d

5 files changed

Lines changed: 58 additions & 4 deletions

File tree

spring/actuator/src/main/java/net/brightroom/endpointgate/spring/actuator/endpoint/EndpointGateEndpoint.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ public EndpointGateEndpointResponse gate(@Selector String gateId) {
108108
* @param scheduleStart the schedule start time, or {@code null} if only an end time is needed
109109
* @param scheduleEnd the schedule end time, or {@code null} for an open-ended schedule
110110
* @param scheduleTimezone the schedule timezone string (e.g. {@code "Asia/Tokyo"}), or {@code
111-
* null} to use the system default timezone
111+
* null} to use the global default timezone ({@code endpoint-gate.schedule.default-timezone}),
112+
* falling back to the system default timezone if no global default is configured
112113
* @param removeSchedule {@code true} to remove the schedule, or {@code null}/{@code false} to
113114
* leave unchanged
114115
* @return a response reflecting the updated state of all gates

spring/actuator/src/main/java/net/brightroom/endpointgate/spring/actuator/endpoint/ReactiveEndpointGateEndpoint.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ public EndpointGateEndpointResponse gate(@Selector String gateId) {
110110
* @param scheduleStart the schedule start time, or {@code null} if only an end time is needed
111111
* @param scheduleEnd the schedule end time, or {@code null} for an open-ended schedule
112112
* @param scheduleTimezone the schedule timezone string (e.g. {@code "Asia/Tokyo"}), or {@code
113-
* null} to use the system default timezone
113+
* null} to use the global default timezone ({@code endpoint-gate.schedule.default-timezone}),
114+
* falling back to the system default timezone if no global default is configured
114115
* @param removeSchedule {@code true} to remove the schedule, or {@code null}/{@code false} to
115116
* leave unchanged
116117
* @return a response reflecting the updated state of all gates

spring/actuator/src/test/java/net/brightroom/endpointgate/spring/actuator/endpoint/ReactiveEndpointGateEndpointTest.java

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,57 @@ void gate_returnsUpdatedSchedule_afterUpdateGate() {
710710
assertThat(response.schedule().start()).isEqualTo(LocalDateTime.of(2026, 4, 1, 0, 0));
711711
}
712712

713+
@Test
714+
void updateGate_usesDefaultScheduleTimezone_whenScheduleTimezoneNotSpecified() {
715+
var provider = new MutableInMemoryReactiveEndpointGateProvider(Map.of("gate-a", true), false);
716+
var scheduleProvider = new MutableInMemoryReactiveScheduleProvider(Map.of());
717+
var endpoint =
718+
new ReactiveEndpointGateEndpoint(
719+
provider,
720+
emptyRolloutProvider(),
721+
emptyConditionProvider(),
722+
scheduleProvider,
723+
false,
724+
ZoneId.of("Asia/Tokyo"),
725+
eventPublisher,
726+
clock);
727+
728+
endpoint.updateGate(
729+
"gate-a", true, null, null, LocalDateTime.of(2026, 6, 1, 0, 0), null, null, null);
730+
731+
assertThat(scheduleProvider.getSchedule("gate-a").blockOptional())
732+
.hasValueSatisfying(s -> assertThat(s.timezone()).isEqualTo(ZoneId.of("Asia/Tokyo")));
733+
}
734+
735+
@Test
736+
void updateGate_usesExplicitTimezone_overDefaultScheduleTimezone() {
737+
var provider = new MutableInMemoryReactiveEndpointGateProvider(Map.of("gate-a", true), false);
738+
var scheduleProvider = new MutableInMemoryReactiveScheduleProvider(Map.of());
739+
var endpoint =
740+
new ReactiveEndpointGateEndpoint(
741+
provider,
742+
emptyRolloutProvider(),
743+
emptyConditionProvider(),
744+
scheduleProvider,
745+
false,
746+
ZoneId.of("Asia/Tokyo"),
747+
eventPublisher,
748+
clock);
749+
750+
endpoint.updateGate(
751+
"gate-a",
752+
true,
753+
null,
754+
null,
755+
LocalDateTime.of(2026, 6, 1, 0, 0),
756+
null,
757+
"America/New_York",
758+
null);
759+
760+
assertThat(scheduleProvider.getSchedule("gate-a").blockOptional())
761+
.hasValueSatisfying(s -> assertThat(s.timezone()).isEqualTo(ZoneId.of("America/New_York")));
762+
}
763+
713764
@Test
714765
void updateGate_throwsIllegalArgumentException_whenOnlyScheduleTimezoneProvided() {
715766
var provider = new MutableInMemoryReactiveEndpointGateProvider(Map.of("gate-a", true), false);

spring/core/src/main/java/net/brightroom/endpointgate/spring/core/properties/GlobalScheduleProperties.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package net.brightroom.endpointgate.spring.core.properties;
22

33
import java.time.ZoneId;
4+
import org.jspecify.annotations.Nullable;
45

56
/**
67
* Global schedule configuration properties.
@@ -23,7 +24,7 @@ public class GlobalScheduleProperties {
2324
*
2425
* @return the default timezone, or {@code null}
2526
*/
26-
public ZoneId defaultTimezone() {
27+
public @Nullable ZoneId defaultTimezone() {
2728
return defaultTimezone;
2829
}
2930

spring/core/src/main/resources/META-INF/additional-spring-configuration-metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
{
5252
"name": "endpoint-gate.gates.[*].schedule.timezone",
5353
"type": "java.time.ZoneId",
54-
"description": "The timezone used to evaluate start and end times. If omitted, the system default timezone is used.",
54+
"description": "The timezone used to evaluate start and end times. If omitted, the global default timezone (endpoint-gate.schedule.default-timezone) is used. If neither is set, the system default timezone is used.",
5555
"defaultValue": "system default"
5656
},
5757
{

0 commit comments

Comments
 (0)