From 07097976efe954d33d4d7104709e06a614e4fc3f Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Fri, 5 Jan 2024 10:08:57 +0100 Subject: [PATCH] Polishing --- .../org/springframework/context/index/sample/Scope.java | 4 ++-- .../context/event/GenericApplicationListener.java | 1 + .../context/event/GenericApplicationListenerDelegate.java | 5 +++-- .../springframework/scheduling/support/CronExpression.java | 4 ++-- .../scheduling/support/CronTriggerTests.java | 7 +++---- .../core/test/tools/CompileWithForkedClassLoader.java | 4 ++-- .../aot/hint/annotation/RegisterReflectionForBinding.java | 4 ++-- .../annotation/ReflectiveRuntimeHintsRegistrarTests.java | 6 ++---- .../core/annotation/MergedAnnotationsTests.java | 4 ++-- .../src/test/java/org/springframework/core/type/Scope.java | 4 ++-- .../core/testfixture/EnabledForTestGroups.java | 4 ++-- .../test/context/junit/jupiter/DisabledOnMac.java | 4 ++-- .../test/context/junit/jupiter/EnabledOnMac.java | 4 ++-- .../test/context/junit/jupiter/FailingTestCase.java | 4 ++-- 14 files changed, 29 insertions(+), 30 deletions(-) diff --git a/spring-context-indexer/src/test/java/org/springframework/context/index/sample/Scope.java b/spring-context-indexer/src/test/java/org/springframework/context/index/sample/Scope.java index b96de6139374..f128d697c984 100644 --- a/spring-context-indexer/src/test/java/org/springframework/context/index/sample/Scope.java +++ b/spring-context-indexer/src/test/java/org/springframework/context/index/sample/Scope.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2009 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,7 +24,7 @@ /** * Copy of the {@code @Scope} annotation for testing purposes. */ -@Target({ ElementType.TYPE, ElementType.METHOD }) +@Target({ElementType.TYPE, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) public @interface Scope { diff --git a/spring-context/src/main/java/org/springframework/context/event/GenericApplicationListener.java b/spring-context/src/main/java/org/springframework/context/event/GenericApplicationListener.java index 185b627b75f1..21e8b79da29a 100644 --- a/spring-context/src/main/java/org/springframework/context/event/GenericApplicationListener.java +++ b/spring-context/src/main/java/org/springframework/context/event/GenericApplicationListener.java @@ -55,6 +55,7 @@ default boolean supportsEventType(Class eventType) { */ boolean supportsEventType(ResolvableType eventType); + /** * Create a new {@code ApplicationListener} for the given event type. * @param eventType the event to listen to diff --git a/spring-context/src/main/java/org/springframework/context/event/GenericApplicationListenerDelegate.java b/spring-context/src/main/java/org/springframework/context/event/GenericApplicationListenerDelegate.java index f152b86c5a82..9b2adac9c30e 100644 --- a/spring-context/src/main/java/org/springframework/context/event/GenericApplicationListenerDelegate.java +++ b/spring-context/src/main/java/org/springframework/context/event/GenericApplicationListenerDelegate.java @@ -22,8 +22,7 @@ import org.springframework.core.ResolvableType; /** - * A {@link GenericApplicationListener} implementation that supports a single - * event type. + * A {@link GenericApplicationListener} implementation that supports a single event type. * * @author Stephane Nicoll * @since 6.1.3 @@ -35,11 +34,13 @@ class GenericApplicationListenerDelegate implements private final Consumer consumer; + GenericApplicationListenerDelegate(Class supportedEventType, Consumer consumer) { this.supportedEventType = supportedEventType; this.consumer = consumer; } + @Override public void onApplicationEvent(ApplicationEvent event) { this.consumer.accept(this.supportedEventType.cast(event)); diff --git a/spring-context/src/main/java/org/springframework/scheduling/support/CronExpression.java b/spring-context/src/main/java/org/springframework/scheduling/support/CronExpression.java index 0e6008de6253..5d58384a3943 100644 --- a/spring-context/src/main/java/org/springframework/scheduling/support/CronExpression.java +++ b/spring-context/src/main/java/org/springframework/scheduling/support/CronExpression.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -168,7 +168,7 @@ private CronExpression(CronField seconds, CronField minutes, CronField hours, * the cron format */ public static CronExpression parse(String expression) { - Assert.hasLength(expression, "Expression string must not be empty"); + Assert.hasLength(expression, "Expression must not be empty"); expression = resolveMacros(expression); diff --git a/spring-context/src/test/java/org/springframework/scheduling/support/CronTriggerTests.java b/spring-context/src/test/java/org/springframework/scheduling/support/CronTriggerTests.java index d1f58624c4c1..910ed03f5319 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/support/CronTriggerTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/support/CronTriggerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -848,6 +848,7 @@ void daylightSavingMissingHour(Date localDateTime, TimeZone timeZone) { assertThat(nextExecutionTime).isEqualTo(this.calendar.getTime()); } + private static void roundup(Calendar calendar) { calendar.add(Calendar.SECOND, 1); calendar.set(Calendar.MILLISECOND, 0); @@ -861,9 +862,7 @@ private static void assertMatchesNextSecond(CronTrigger trigger, Calendar calend } private static TriggerContext getTriggerContext(Date lastCompletionTime) { - SimpleTriggerContext context = new SimpleTriggerContext(); - context.update(null, null, lastCompletionTime); - return context; + return new SimpleTriggerContext(null, null, lastCompletionTime); } diff --git a/spring-core-test/src/main/java/org/springframework/core/test/tools/CompileWithForkedClassLoader.java b/spring-core-test/src/main/java/org/springframework/core/test/tools/CompileWithForkedClassLoader.java index 35307a2716a8..768c18b9e211 100644 --- a/spring-core-test/src/main/java/org/springframework/core/test/tools/CompileWithForkedClassLoader.java +++ b/spring-core-test/src/main/java/org/springframework/core/test/tools/CompileWithForkedClassLoader.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,8 +41,8 @@ * @author Sam Brannen * @since 6.0 */ +@Target({ElementType.TYPE, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) -@Target({ ElementType.TYPE, ElementType.METHOD }) @Documented @ExtendWith(CompileWithForkedClassLoaderExtension.class) public @interface CompileWithForkedClassLoader { diff --git a/spring-core/src/main/java/org/springframework/aot/hint/annotation/RegisterReflectionForBinding.java b/spring-core/src/main/java/org/springframework/aot/hint/annotation/RegisterReflectionForBinding.java index d0a5b9c98ba9..0d1e56f259f5 100644 --- a/spring-core/src/main/java/org/springframework/aot/hint/annotation/RegisterReflectionForBinding.java +++ b/spring-core/src/main/java/org/springframework/aot/hint/annotation/RegisterReflectionForBinding.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -63,7 +63,7 @@ * @see org.springframework.aot.hint.BindingReflectionHintsRegistrar * @see Reflective @Reflective */ -@Target({ ElementType.TYPE, ElementType.METHOD }) +@Target({ElementType.TYPE, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) @Documented @Reflective(RegisterReflectionForBindingProcessor.class) diff --git a/spring-core/src/test/java/org/springframework/aot/hint/annotation/ReflectiveRuntimeHintsRegistrarTests.java b/spring-core/src/test/java/org/springframework/aot/hint/annotation/ReflectiveRuntimeHintsRegistrarTests.java index f19689812ae0..f4b92183a1a1 100644 --- a/spring-core/src/test/java/org/springframework/aot/hint/annotation/ReflectiveRuntimeHintsRegistrarTests.java +++ b/spring-core/src/test/java/org/springframework/aot/hint/annotation/ReflectiveRuntimeHintsRegistrarTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -224,7 +224,6 @@ public void notManaged() { @interface SampleInvoker { int retries() default 0; - } @Target({ ElementType.METHOD }) @@ -235,10 +234,9 @@ public void notManaged() { @AliasFor(attribute = "retries", annotation = SampleInvoker.class) int value() default 1; - } - @Target({ ElementType.TYPE }) + @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @Documented @Reflective(TestTypeHintReflectiveProcessor.class) diff --git a/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsTests.java b/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsTests.java index 912e64d54682..d4ad78965aff 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsTests.java @@ -2273,8 +2273,8 @@ void asAnnotationAttributesReturnsPopulatedAnnotationAttributes() { // @formatter:off + @Target({ElementType.TYPE, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) - @Target({ ElementType.TYPE, ElementType.METHOD }) @Inherited @interface Transactional { @@ -2327,8 +2327,8 @@ static class ComposedTransactionalComponentClass { static class AliasedTransactionalComponentClass { } + @Target({ElementType.TYPE, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) - @Target({ ElementType.TYPE, ElementType.METHOD }) @Inherited @interface AliasedTransactional { diff --git a/spring-core/src/test/java/org/springframework/core/type/Scope.java b/spring-core/src/test/java/org/springframework/core/type/Scope.java index eb581928a96b..4b10cac0c66d 100644 --- a/spring-core/src/test/java/org/springframework/core/type/Scope.java +++ b/spring-core/src/test/java/org/springframework/core/type/Scope.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2009 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,7 +24,7 @@ /** * Copy of the {@code @Scope} annotation for testing purposes. */ -@Target({ ElementType.TYPE, ElementType.METHOD }) +@Target({ElementType.TYPE, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) public @interface Scope { diff --git a/spring-core/src/testFixtures/java/org/springframework/core/testfixture/EnabledForTestGroups.java b/spring-core/src/testFixtures/java/org/springframework/core/testfixture/EnabledForTestGroups.java index 490f42811edb..fbf32bf8015e 100644 --- a/spring-core/src/testFixtures/java/org/springframework/core/testfixture/EnabledForTestGroups.java +++ b/spring-core/src/testFixtures/java/org/springframework/core/testfixture/EnabledForTestGroups.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,7 +32,7 @@ * @author Sam Brannen * @since 5.2 */ -@Target({ ElementType.TYPE, ElementType.METHOD }) +@Target({ElementType.TYPE, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) @Documented @Inherited diff --git a/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/DisabledOnMac.java b/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/DisabledOnMac.java index 1c0c259203ad..534b9718400e 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/DisabledOnMac.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/DisabledOnMac.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,7 +30,7 @@ * @author Sam Brannen * @since 5.0 */ -@Target({ ElementType.TYPE, ElementType.METHOD }) +@Target({ElementType.TYPE, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) @Documented @DisabledIf(expression = "#{systemProperties['os.name'].toLowerCase().contains('mac')}", reason = "Disabled on Mac OS") diff --git a/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/EnabledOnMac.java b/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/EnabledOnMac.java index aad34adabfc2..c847b443b514 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/EnabledOnMac.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/EnabledOnMac.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,7 +30,7 @@ * @author Sam Brannen * @since 5.0 */ -@Target({ ElementType.TYPE, ElementType.METHOD }) +@Target({ElementType.TYPE, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) @Documented @EnabledIf(expression = "#{systemProperties['os.name'].toLowerCase().contains('mac')}", reason = "Enabled on Mac OS") diff --git a/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/FailingTestCase.java b/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/FailingTestCase.java index 1f3ab5d374bb..e4cae672215c 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/FailingTestCase.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/FailingTestCase.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,7 +31,7 @@ * @author Sam Brannen * @since 5.1 */ -@Target({ ElementType.TYPE, ElementType.METHOD }) +@Target({ElementType.TYPE, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) @Documented @Tag("failing-test-case")