Browse Source

Merge pull request #31076 from 70825

* pr/31076:
  Polish "Wrap ternary operator within parentheses"
  Wrap ternary operator within parentheses

Closes gh-31076
pull/31091/head
Stephane Nicoll 2 years ago
parent
commit
9c175608e5
  1. 4
      framework-docs/src/main/java/org/springframework/docs/integration/observability/config/conventions/CustomServerRequestObservationConvention.java
  2. 2
      spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AspectJBeanFactoryInitializationAotProcessor.java
  3. 5
      spring-aop/src/main/java/org/springframework/aop/config/AspectEntry.java
  4. 4
      spring-aop/src/test/java/org/springframework/aop/interceptor/ConcurrencyThrottleInterceptorTests.java
  5. 6
      spring-aspects/src/test/java/org/springframework/transaction/aspectj/TransactionAspectTests.java
  6. 6
      spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java
  7. 2
      spring-beans/src/main/java/org/springframework/beans/factory/aot/BeanDefinitionPropertiesCodeGenerator.java
  8. 4
      spring-beans/src/main/java/org/springframework/beans/factory/groovy/GroovyBeanDefinitionReader.java
  9. 2
      spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java
  10. 2
      spring-beans/src/main/java/org/springframework/beans/factory/support/AutowireUtils.java
  11. 2
      spring-beans/src/test/java/org/springframework/beans/factory/support/Spr8954Tests.java
  12. 4
      spring-context-support/src/test/java/org/springframework/cache/caffeine/CaffeineCacheTests.java
  13. 4
      spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheEhCacheApiTests.java
  14. 2
      spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/AbstractCacheOperationTests.java
  15. 4
      spring-context/src/main/java/org/springframework/context/support/DelegatingMessageSource.java
  16. 6
      spring-context/src/main/java/org/springframework/scheduling/TriggerContext.java
  17. 4
      spring-context/src/main/java/org/springframework/scheduling/support/SimpleTriggerContext.java
  18. 4
      spring-context/src/main/java/org/springframework/validation/beanvalidation/MethodValidationAdapter.java
  19. 2
      spring-context/src/test/java/org/springframework/beans/factory/xml/support/CustomNamespaceHandlerTests.java
  20. 4
      spring-context/src/test/java/org/springframework/cache/concurrent/ConcurrentMapCacheTests.java
  21. 2
      spring-context/src/test/java/org/springframework/context/annotation/Spr8954Tests.java
  22. 2
      spring-context/src/test/java/org/springframework/context/event/ApplicationContextEventTests.java
  23. 2
      spring-context/src/test/java/org/springframework/context/support/ResourceBundleMessageSourceTests.java
  24. 2
      spring-context/src/test/java/org/springframework/format/datetime/standard/DateTimeFormatterFactoryTests.java
  25. 4
      spring-context/src/test/java/org/springframework/jmx/export/NotificationListenerTests.java
  26. 2
      spring-core-test/src/main/java/org/springframework/core/test/tools/CompileWithForkedClassLoaderClassLoader.java
  27. 2
      spring-core-test/src/main/java/org/springframework/core/test/tools/DynamicClassLoader.java
  28. 6
      spring-core-test/src/main/java/org/springframework/core/test/tools/TestCompiler.java
  29. 4
      spring-core/src/jmh/java/org/springframework/util/StringUtilsBenchmark.java
  30. 4
      spring-core/src/main/java/org/springframework/aot/generate/GeneratedClass.java
  31. 4
      spring-core/src/main/java/org/springframework/aot/generate/InMemoryGeneratedFiles.java
  32. 2
      spring-core/src/main/java/org/springframework/aot/generate/MethodName.java
  33. 4
      spring-core/src/main/java/org/springframework/aot/hint/ResourceHints.java
  34. 6
      spring-core/src/main/java/org/springframework/aot/hint/SimpleTypeReference.java
  35. 2
      spring-core/src/main/java/org/springframework/aot/hint/support/FilePatternResourceHintsRegistrar.java
  36. 2
      spring-core/src/main/java/org/springframework/core/codec/ResourceDecoder.java
  37. 6
      spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMapping.java
  38. 2
      spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceHttpRequestHandler.java
  39. 6
      spring-webmvc/src/main/java/org/springframework/web/servlet/view/ContentNegotiatingViewResolver.java

4
framework-docs/src/main/java/org/springframework/docs/integration/observability/config/conventions/CustomServerRequestObservationConvention.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 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.
@ -59,7 +59,7 @@ public class CustomServerRequestObservationConvention implements ServerRequestOb @@ -59,7 +59,7 @@ public class CustomServerRequestObservationConvention implements ServerRequestOb
}
private KeyValue exception(ServerRequestObservationContext context) {
String exception = (context.getError() != null) ? context.getError().getClass().getSimpleName() : KeyValue.NONE_VALUE;
String exception = (context.getError() != null ? context.getError().getClass().getSimpleName() : KeyValue.NONE_VALUE);
return KeyValue.of(ServerHttpObservationDocumentation.LowCardinalityKeyNames.EXCEPTION, exception);
}

2
spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AspectJBeanFactoryInitializationAotProcessor.java

@ -61,7 +61,7 @@ class AspectJBeanFactoryInitializationAotProcessor implements BeanFactoryInitial @@ -61,7 +61,7 @@ class AspectJBeanFactoryInitializationAotProcessor implements BeanFactoryInitial
private static AspectContribution processAheadOfTime(ConfigurableListableBeanFactory beanFactory) {
BeanFactoryAspectJAdvisorsBuilder builder = new BeanFactoryAspectJAdvisorsBuilder(beanFactory);
List<Advisor> advisors = builder.buildAspectJAdvisors();
return advisors.isEmpty() ? null : new AspectContribution(advisors);
return (advisors.isEmpty() ? null : new AspectContribution(advisors));
}
}

5
spring-aop/src/main/java/org/springframework/aop/config/AspectEntry.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2023 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.
@ -46,7 +46,8 @@ public class AspectEntry implements ParseState.Entry { @@ -46,7 +46,8 @@ public class AspectEntry implements ParseState.Entry {
@Override
public String toString() {
return "Aspect: " + (StringUtils.hasLength(this.id) ? "id='" + this.id + "'" : "ref='" + this.ref + "'");
return "Aspect: " + (StringUtils.hasLength(this.id) ? "id='" + this.id + "'"
: "ref='" + this.ref + "'");
}
}

4
spring-aop/src/test/java/org/springframework/aop/interceptor/ConcurrencyThrottleInterceptorTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2023 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.
@ -95,7 +95,7 @@ public class ConcurrencyThrottleInterceptorTests { @@ -95,7 +95,7 @@ public class ConcurrencyThrottleInterceptorTests {
ex.printStackTrace();
}
threads[i] = new ConcurrencyThread(proxy,
i % 2 == 0 ? new OutOfMemoryError() : new IllegalStateException());
(i % 2 == 0 ? new OutOfMemoryError() : new IllegalStateException()));
threads[i].start();
}
for (int i = 0; i < NR_OF_THREADS; i++) {

6
spring-aspects/src/test/java/org/springframework/transaction/aspectj/TransactionAspectTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 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.
@ -157,9 +157,9 @@ public class TransactionAspectTests { @@ -157,9 +157,9 @@ public class TransactionAspectTests {
}
finally {
assertThat(txManager.begun).isEqualTo(1);
long expected1 = rollback ? 0 : 1;
long expected1 = (rollback ? 0 : 1);
assertThat(txManager.commits).isEqualTo(expected1);
long expected = rollback ? 1 : 0;
long expected = (rollback ? 1 : 0);
assertThat(txManager.rollbacks).isEqualTo(expected);
}
}

6
spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java

@ -1007,7 +1007,7 @@ public class AutowiredAnnotationBeanPostProcessor implements SmartInstantiationA @@ -1007,7 +1007,7 @@ public class AutowiredAnnotationBeanPostProcessor implements SmartInstantiationA
hints.reflection().registerField(field);
CodeBlock resolver = CodeBlock.of("$T.$L($S)",
AutowiredFieldValueResolver.class,
(!required) ? "forField" : "forRequiredField", field.getName());
(!required ? "forField" : "forRequiredField"), field.getName());
AccessControl accessControl = AccessControl.forMember(field);
if (!accessControl.isAccessibleFrom(targetClassName)) {
return CodeBlock.of("$L.resolveAndSet($L, $L)", resolver,
@ -1022,7 +1022,7 @@ public class AutowiredAnnotationBeanPostProcessor implements SmartInstantiationA @@ -1022,7 +1022,7 @@ public class AutowiredAnnotationBeanPostProcessor implements SmartInstantiationA
CodeBlock.Builder code = CodeBlock.builder();
code.add("$T.$L", AutowiredMethodArgumentsResolver.class,
(!required) ? "forMethod" : "forRequiredMethod");
(!required ? "forMethod" : "forRequiredMethod"));
code.add("($S", method.getName());
if (method.getParameterCount() > 0) {
code.add(", $L", generateParameterTypesCode(method.getParameterTypes()));
@ -1047,7 +1047,7 @@ public class AutowiredAnnotationBeanPostProcessor implements SmartInstantiationA @@ -1047,7 +1047,7 @@ public class AutowiredAnnotationBeanPostProcessor implements SmartInstantiationA
private CodeBlock generateParameterTypesCode(Class<?>[] parameterTypes) {
CodeBlock.Builder code = CodeBlock.builder();
for (int i = 0; i < parameterTypes.length; i++) {
code.add(i != 0 ? ", " : "");
code.add((i != 0 ? ", " : ""));
code.add("$T.class", parameterTypes[i]);
}
return code.build();

2
spring-beans/src/main/java/org/springframework/beans/factory/aot/BeanDefinitionPropertiesCodeGenerator.java

@ -316,7 +316,7 @@ class BeanDefinitionPropertiesCodeGenerator { @@ -316,7 +316,7 @@ class BeanDefinitionPropertiesCodeGenerator {
private static final ThreadLocal<ArrayDeque<String>> threadLocal = ThreadLocal.withInitial(ArrayDeque::new);
static void push(@Nullable String name) {
String valueToSet = (name != null) ? name : "";
String valueToSet = (name != null ? name : "");
threadLocal.get().push(valueToSet);
}

4
spring-beans/src/main/java/org/springframework/beans/factory/groovy/GroovyBeanDefinitionReader.java

@ -489,7 +489,7 @@ public class GroovyBeanDefinitionReader extends AbstractBeanDefinitionReader imp @@ -489,7 +489,7 @@ public class GroovyBeanDefinitionReader extends AbstractBeanDefinitionReader imp
// named constructor arguments
if (args.length > 1 && args[1] instanceof Class<?> clazz) {
List<Object> constructorArgs =
resolveConstructorArguments(args, 2, hasClosureArgument ? args.length - 1 : args.length);
resolveConstructorArguments(args, 2, (hasClosureArgument ? args.length - 1 : args.length));
this.currentBeanDefinition = new GroovyBeanDefinitionWrapper(beanName, clazz, constructorArgs);
for (Map.Entry<?, ?> entity : namedArgs.entrySet()) {
String propName = (String) entity.getKey();
@ -525,7 +525,7 @@ public class GroovyBeanDefinitionReader extends AbstractBeanDefinitionReader imp @@ -525,7 +525,7 @@ public class GroovyBeanDefinitionReader extends AbstractBeanDefinitionReader imp
}
else {
List<Object> constructorArgs =
resolveConstructorArguments(args, 0, hasClosureArgument ? args.length - 1 : args.length);
resolveConstructorArguments(args, 0, (hasClosureArgument ? args.length - 1 : args.length));
this.currentBeanDefinition = new GroovyBeanDefinitionWrapper(beanName, null, constructorArgs);
}

2
spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java

@ -734,7 +734,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp @@ -734,7 +734,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
aliases.add(fullBeanName);
}
String[] retrievedAliases = super.getAliases(beanName);
String prefix = factoryPrefix ? FACTORY_BEAN_PREFIX : "";
String prefix = (factoryPrefix ? FACTORY_BEAN_PREFIX : "");
for (String retrievedAlias : retrievedAliases) {
String alias = prefix + retrievedAlias;
if (!alias.equals(name)) {

2
spring-beans/src/main/java/org/springframework/beans/factory/support/AutowireUtils.java

@ -53,7 +53,7 @@ abstract class AutowireUtils { @@ -53,7 +53,7 @@ abstract class AutowireUtils {
public static final Comparator<Executable> EXECUTABLE_COMPARATOR = (e1, e2) -> {
int result = Boolean.compare(Modifier.isPublic(e2.getModifiers()), Modifier.isPublic(e1.getModifiers()));
return result != 0 ? result : Integer.compare(e2.getParameterCount(), e1.getParameterCount());
return (result != 0 ? result : Integer.compare(e2.getParameterCount(), e1.getParameterCount()));
};

2
spring-beans/src/test/java/org/springframework/beans/factory/support/Spr8954Tests.java

@ -129,7 +129,7 @@ public class Spr8954Tests { @@ -129,7 +129,7 @@ public class Spr8954Tests {
@Override
public Class<?> predictBeanType(Class<?> beanClass, String beanName) {
return FactoryBean.class.isAssignableFrom(beanClass) ? PredictedType.class : null;
return (FactoryBean.class.isAssignableFrom(beanClass) ? PredictedType.class : null);
}
}

4
spring-context-support/src/test/java/org/springframework/cache/caffeine/CaffeineCacheTests.java vendored

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 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.
@ -57,7 +57,7 @@ class CaffeineCacheTests extends AbstractValueAdaptingCacheTests<CaffeineCache> @@ -57,7 +57,7 @@ class CaffeineCacheTests extends AbstractValueAdaptingCacheTests<CaffeineCache>
@Override
protected CaffeineCache getCache(boolean allowNull) {
return allowNull ? this.cache : this.cacheNoNull;
return (allowNull ? this.cache : this.cacheNoNull);
}
@Override

4
spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheEhCacheApiTests.java vendored

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2023 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.
@ -71,7 +71,7 @@ public class JCacheEhCacheApiTests extends AbstractValueAdaptingCacheTests<JCach @@ -71,7 +71,7 @@ public class JCacheEhCacheApiTests extends AbstractValueAdaptingCacheTests<JCach
@Override
protected JCacheCache getCache(boolean allowNull) {
return allowNull ? this.cache : this.cacheNoNull;
return (allowNull ? this.cache : this.cacheNoNull);
}
@Override

2
spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/AbstractCacheOperationTests.java vendored

@ -70,7 +70,7 @@ public abstract class AbstractCacheOperationTests<O extends JCacheOperation<?>> @@ -70,7 +70,7 @@ public abstract class AbstractCacheOperationTests<O extends JCacheOperation<?>>
private static String getCacheName(Annotation annotation) {
Object cacheName = AnnotationUtils.getValue(annotation, "cacheName");
return cacheName != null ? cacheName.toString() : "test";
return (cacheName != null ? cacheName.toString() : "test");
}
}

4
spring-context/src/main/java/org/springframework/context/support/DelegatingMessageSource.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2023 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.
@ -95,7 +95,7 @@ public class DelegatingMessageSource extends MessageSourceSupport implements Hie @@ -95,7 +95,7 @@ public class DelegatingMessageSource extends MessageSourceSupport implements Hie
@Override
public String toString() {
return this.parentMessageSource != null ? this.parentMessageSource.toString() : "Empty MessageSource";
return (this.parentMessageSource != null ? this.parentMessageSource.toString() : "Empty MessageSource");
}
}

6
spring-context/src/main/java/org/springframework/scheduling/TriggerContext.java

@ -52,7 +52,7 @@ public interface TriggerContext { @@ -52,7 +52,7 @@ public interface TriggerContext {
@Deprecated(since = "6.0")
default Date lastScheduledExecutionTime() {
Instant instant = lastScheduledExecution();
return instant != null ? Date.from(instant) : null;
return (instant != null ? Date.from(instant) : null);
}
/**
@ -73,7 +73,7 @@ public interface TriggerContext { @@ -73,7 +73,7 @@ public interface TriggerContext {
@Deprecated(since = "6.0")
default Date lastActualExecutionTime() {
Instant instant = lastActualExecution();
return instant != null ? Date.from(instant) : null;
return (instant != null ? Date.from(instant) : null);
}
/**
@ -94,7 +94,7 @@ public interface TriggerContext { @@ -94,7 +94,7 @@ public interface TriggerContext {
@Nullable
default Date lastCompletionTime() {
Instant instant = lastCompletion();
return instant != null ? Date.from(instant) : null;
return (instant != null ? Date.from(instant) : null);
}
/**

4
spring-context/src/main/java/org/springframework/scheduling/support/SimpleTriggerContext.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 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.
@ -68,7 +68,7 @@ public class SimpleTriggerContext implements TriggerContext { @@ -68,7 +68,7 @@ public class SimpleTriggerContext implements TriggerContext {
@Nullable
private static Instant toInstant(@Nullable Date date) {
return date != null ? date.toInstant() : null;
return (date != null ? date.toInstant() : null);
}
/**

4
spring-context/src/main/java/org/springframework/validation/beanvalidation/MethodValidationAdapter.java

@ -225,7 +225,7 @@ public class MethodValidationAdapter implements MethodValidator { @@ -225,7 +225,7 @@ public class MethodValidationAdapter implements MethodValidator {
}
return adaptViolations(target, method, violations,
i -> parameters != null ? parameters[i] : initMethodParameter(method, i),
i -> (parameters != null ? parameters[i] : initMethodParameter(method, i)),
i -> arguments[i]);
}
@ -263,7 +263,7 @@ public class MethodValidationAdapter implements MethodValidator { @@ -263,7 +263,7 @@ public class MethodValidationAdapter implements MethodValidator {
}
return adaptViolations(target, method, violations,
i -> returnType != null ? returnType : initMethodParameter(method, -1),
i -> (returnType != null ? returnType : initMethodParameter(method, -1)),
i -> returnValue);
}

2
spring-context/src/test/java/org/springframework/beans/factory/xml/support/CustomNamespaceHandlerTests.java

@ -260,7 +260,7 @@ final class TestNamespaceHandler extends NamespaceHandlerSupport { @@ -260,7 +260,7 @@ final class TestNamespaceHandler extends NamespaceHandlerSupport {
Element element = (Element) node;
BeanDefinition def = definition.getBeanDefinition();
MutablePropertyValues mpvs = (def.getPropertyValues() == null) ? new MutablePropertyValues() : def.getPropertyValues();
MutablePropertyValues mpvs = (def.getPropertyValues() == null ? new MutablePropertyValues() : def.getPropertyValues());
mpvs.add("name", element.getAttribute("name"));
mpvs.add("age", element.getAttribute("age"));

4
spring-context/src/test/java/org/springframework/cache/concurrent/ConcurrentMapCacheTests.java vendored

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 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 @@ public class ConcurrentMapCacheTests extends AbstractValueAdaptingCacheTests<Con @@ -63,7 +63,7 @@ public class ConcurrentMapCacheTests extends AbstractValueAdaptingCacheTests<Con
@Override
protected ConcurrentMapCache getCache(boolean allowNull) {
return allowNull ? this.cache : this.cacheNoNull;
return (allowNull ? this.cache : this.cacheNoNull);
}
@Override

2
spring-context/src/test/java/org/springframework/context/annotation/Spr8954Tests.java

@ -128,7 +128,7 @@ public class Spr8954Tests { @@ -128,7 +128,7 @@ public class Spr8954Tests {
@Override
public Class<?> predictBeanType(Class<?> beanClass, String beanName) {
return FactoryBean.class.isAssignableFrom(beanClass) ? PredictedType.class : null;
return (FactoryBean.class.isAssignableFrom(beanClass) ? PredictedType.class : null);
}
@Override

2
spring-context/src/test/java/org/springframework/context/event/ApplicationContextEventTests.java

@ -131,7 +131,7 @@ public class ApplicationContextEventTests extends AbstractApplicationEventListen @@ -131,7 +131,7 @@ public class ApplicationContextEventTests extends AbstractApplicationEventListen
else {
smc.multicastEvent(event);
}
int invocation = match ? 1 : 0;
int invocation = (match ? 1 : 0);
verify(listener, times(invocation)).onApplicationEvent(event);
}

2
spring-context/src/test/java/org/springframework/context/support/ResourceBundleMessageSourceTests.java

@ -132,7 +132,7 @@ class ResourceBundleMessageSourceTests { @@ -132,7 +132,7 @@ class ResourceBundleMessageSourceTests {
Locale.setDefault(expectGermanFallback ? Locale.GERMAN : Locale.CANADA);
assertThat(ac.getMessage("code1", null, Locale.ENGLISH)).isEqualTo("message1");
Object expected = fallbackToSystemLocale && expectGermanFallback ? "nachricht2" : "message2";
Object expected = (fallbackToSystemLocale && expectGermanFallback ? "nachricht2" : "message2");
assertThat(ac.getMessage("code2", null, Locale.ENGLISH)).isEqualTo(expected);
assertThat(ac.getMessage("code2", null, Locale.GERMAN)).isEqualTo("nachricht2");

2
spring-context/src/test/java/org/springframework/format/datetime/standard/DateTimeFormatterFactoryTests.java

@ -41,7 +41,7 @@ public class DateTimeFormatterFactoryTests { @@ -41,7 +41,7 @@ public class DateTimeFormatterFactoryTests {
private static final TimeZone NEW_YORK = TimeZone.getTimeZone("America/New_York");
// Ensure that we are testing against a timezone other than the default.
private static final TimeZone TEST_TIMEZONE = ZURICH.equals(TimeZone.getDefault()) ? NEW_YORK : ZURICH;
private static final TimeZone TEST_TIMEZONE = (ZURICH.equals(TimeZone.getDefault()) ? NEW_YORK : ZURICH);
private DateTimeFormatterFactory factory = new DateTimeFormatterFactory();

4
spring-context/src/test/java/org/springframework/jmx/export/NotificationListenerTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 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.
@ -468,7 +468,7 @@ public class NotificationListenerTests extends AbstractMBeanServerTests { @@ -468,7 +468,7 @@ public class NotificationListenerTests extends AbstractMBeanServerTests {
public int getCount(String attribute) {
Integer count = (Integer) this.attributeCounts.get(attribute);
return (count == null) ? 0 : count;
return (count == null ? 0 : count);
}
public Object getLastHandback(String attributeName) {

2
spring-core-test/src/main/java/org/springframework/core/test/tools/CompileWithForkedClassLoaderClassLoader.java

@ -70,7 +70,7 @@ final class CompileWithForkedClassLoaderClassLoader extends ClassLoader { @@ -70,7 +70,7 @@ final class CompileWithForkedClassLoaderClassLoader extends ClassLoader {
@Override
protected Class<?> findClass(String name) throws ClassNotFoundException {
byte[] bytes = findClassBytes(name);
return (bytes != null) ? defineClass(name, bytes, 0, bytes.length, null) : super.findClass(name);
return (bytes != null ? defineClass(name, bytes, 0, bytes.length, null) : super.findClass(name));
}
@Nullable

2
spring-core-test/src/main/java/org/springframework/core/test/tools/DynamicClassLoader.java

@ -139,7 +139,7 @@ public class DynamicClassLoader extends ClassLoader { @@ -139,7 +139,7 @@ public class DynamicClassLoader extends ClassLoader {
return classFile.getContent();
}
DynamicClassFileObject dynamicClassFile = this.dynamicClassFiles.get(name);
return (dynamicClassFile != null) ? dynamicClassFile.getBytes() : null;
return (dynamicClassFile != null ? dynamicClassFile.getBytes() : null);
}
@SuppressWarnings("deprecation") // on JDK 20

6
spring-core-test/src/main/java/org/springframework/core/test/tools/TestCompiler.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 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.
@ -265,8 +265,8 @@ public final class TestCompiler { @@ -265,8 +265,8 @@ public final class TestCompiler {
}
private DynamicClassLoader compile() {
ClassLoader classLoaderToUse = (this.classLoader != null) ? this.classLoader
: Thread.currentThread().getContextClassLoader();
ClassLoader classLoaderToUse = (this.classLoader != null ? this.classLoader
: Thread.currentThread().getContextClassLoader());
List<DynamicJavaFileObject> compilationUnits = this.sourceFiles.stream().map(
DynamicJavaFileObject::new).toList();
StandardJavaFileManager standardFileManager = this.compiler.getStandardFileManager(

4
spring-core/src/jmh/java/org/springframework/util/StringUtilsBenchmark.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2023 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.
@ -100,7 +100,7 @@ public class StringUtilsBenchmark { @@ -100,7 +100,7 @@ public class StringUtilsBenchmark {
}
private String createSamplePath(Random random) {
String separator = random.nextBoolean() ? "/" : "\\";
String separator = (random.nextBoolean() ? "/" : "\\");
StringBuilder sb = new StringBuilder();
sb.append("jar:file:///c:");
for (int i = 0; i < this.segmentCount; i++) {

4
spring-core/src/main/java/org/springframework/aot/generate/GeneratedClass.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 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.
@ -90,7 +90,7 @@ public final class GeneratedClass { @@ -90,7 +90,7 @@ public final class GeneratedClass {
private String generateSequencedMethodName(MethodName name) {
int sequence = this.methodNameSequenceGenerator
.computeIfAbsent(name, key -> new AtomicInteger()).getAndIncrement();
return (sequence > 0) ? name.toString() + sequence : name.toString();
return (sequence > 0 ? name.toString() + sequence : name.toString());
}
/**

4
spring-core/src/main/java/org/springframework/aot/generate/InMemoryGeneratedFiles.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 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.
@ -86,7 +86,7 @@ public class InMemoryGeneratedFiles implements GeneratedFiles { @@ -86,7 +86,7 @@ public class InMemoryGeneratedFiles implements GeneratedFiles {
Assert.notNull(kind, "'kind' must not be null");
Assert.hasLength(path, "'path' must not be empty");
Map<String, InputStreamSource> paths = this.files.get(kind);
return (paths != null) ? paths.get(path) : null;
return (paths != null ? paths.get(path) : null);
}
}

2
spring-core/src/main/java/org/springframework/aot/generate/MethodName.java

@ -116,7 +116,7 @@ final class MethodName { @@ -116,7 +116,7 @@ final class MethodName {
StringBuilder name = new StringBuilder(chars.length);
boolean uppercase = false;
for (char ch : chars) {
char outputChar = (!uppercase) ? ch : Character.toUpperCase(ch);
char outputChar = (!uppercase ? ch : Character.toUpperCase(ch));
name.append((!Character.isLetter(ch)) ? "" : outputChar);
uppercase = (ch == '.');
}

4
spring-core/src/main/java/org/springframework/aot/hint/ResourceHints.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 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.
@ -80,7 +80,7 @@ public class ResourceHints { @@ -80,7 +80,7 @@ public class ResourceHints {
*/
public ResourceHints registerPatternIfPresent(@Nullable ClassLoader classLoader, String location,
Consumer<ResourcePatternHints.Builder> resourceHint) {
ClassLoader classLoaderToUse = (classLoader != null) ? classLoader : getClass().getClassLoader();
ClassLoader classLoaderToUse = (classLoader != null ? classLoader : getClass().getClassLoader());
if (classLoaderToUse.getResource(location) != null) {
registerPattern(resourceHint);
}

6
spring-core/src/main/java/org/springframework/aot/hint/SimpleTypeReference.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 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.
@ -73,7 +73,7 @@ final class SimpleTypeReference extends AbstractTypeReference { @@ -73,7 +73,7 @@ final class SimpleTypeReference extends AbstractTypeReference {
return new SimpleTypeReference(className.substring(0, i), className.substring(i + 1), null);
}
else {
String packageName = isPrimitive(className) ? "java.lang" : "";
String packageName = (isPrimitive(className) ? "java.lang" : "");
return new SimpleTypeReference(packageName, className, null);
}
}
@ -101,7 +101,7 @@ final class SimpleTypeReference extends AbstractTypeReference { @@ -101,7 +101,7 @@ final class SimpleTypeReference extends AbstractTypeReference {
if (type == null) {
return;
}
String typeName = (type.getEnclosingType() != null) ? "." + type.getSimpleName() : type.getSimpleName();
String typeName = (type.getEnclosingType() != null ? "." + type.getSimpleName() : type.getSimpleName());
sb.insert(0, typeName);
buildName(type.getEnclosingType(), sb);
}

2
spring-core/src/main/java/org/springframework/aot/hint/support/FilePatternResourceHintsRegistrar.java

@ -73,7 +73,7 @@ public class FilePatternResourceHintsRegistrar { @@ -73,7 +73,7 @@ public class FilePatternResourceHintsRegistrar {
@Deprecated(since = "6.0.12", forRemoval = true)
public void registerHints(ResourceHints hints, @Nullable ClassLoader classLoader) {
ClassLoader classLoaderToUse = (classLoader != null) ? classLoader : getClass().getClassLoader();
ClassLoader classLoaderToUse = (classLoader != null ? classLoader : getClass().getClassLoader());
List<String> includes = new ArrayList<>();
for (String location : this.locations) {
if (classLoaderToUse.getResource(location) != null) {

2
spring-core/src/main/java/org/springframework/core/codec/ResourceDecoder.java

@ -76,7 +76,7 @@ public class ResourceDecoder extends AbstractDataBufferDecoder<Resource> { @@ -76,7 +76,7 @@ public class ResourceDecoder extends AbstractDataBufferDecoder<Resource> {
}
Class<?> clazz = elementType.toClass();
String filename = hints != null ? (String) hints.get(FILENAME_HINT) : null;
String filename = (hints != null ? (String) hints.get(FILENAME_HINT) : null);
if (clazz == InputStreamResource.class) {
return new InputStreamResource(new ByteArrayInputStream(bytes)) {
@Override

6
spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMapping.java

@ -399,7 +399,7 @@ public abstract class AbstractHandlerMapping extends WebApplicationObjectSupport @@ -399,7 +399,7 @@ public abstract class AbstractHandlerMapping extends WebApplicationObjectSupport
}
protected String formatMappingName() {
return this.beanName != null ? "'" + this.beanName + "'" : getClass().getName();
return (this.beanName != null ? "'" + this.beanName + "'" : getClass().getName());
}
@ -589,9 +589,9 @@ public abstract class AbstractHandlerMapping extends WebApplicationObjectSupport @@ -589,9 +589,9 @@ public abstract class AbstractHandlerMapping extends WebApplicationObjectSupport
private RequestPath getRequestPath(HttpServletRequest request) {
// Expect pre-parsed path with DispatcherServlet,
// but otherwise parse per handler lookup + cache for handling
return request.getAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE) != null ?
return (request.getAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE) != null ?
ServletRequestPathUtils.getParsedRequestPath(request) :
ServletRequestPathUtils.parseAndCache(request);
ServletRequestPathUtils.parseAndCache(request));
}
/**

2
spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceHttpRequestHandler.java

@ -676,7 +676,7 @@ public class ResourceHttpRequestHandler extends WebContentGenerator @@ -676,7 +676,7 @@ public class ResourceHttpRequestHandler extends WebContentGenerator
prev = curr;
}
}
return sb != null ? sb.toString() : path;
return (sb != null ? sb.toString() : path);
}
private String cleanLeadingSlash(String path) {

6
spring-webmvc/src/main/java/org/springframework/web/servlet/view/ContentNegotiatingViewResolver.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2023 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.
@ -233,8 +233,8 @@ public class ContentNegotiatingViewResolver extends WebApplicationObjectSupport @@ -233,8 +233,8 @@ public class ContentNegotiatingViewResolver extends WebApplicationObjectSupport
}
}
String mediaTypeInfo = logger.isDebugEnabled() && requestedMediaTypes != null ?
" given " + requestedMediaTypes.toString() : "";
String mediaTypeInfo = (logger.isDebugEnabled() && requestedMediaTypes != null ?
" given " + requestedMediaTypes.toString() : "");
if (this.useNotAcceptableStatusCode) {
if (logger.isDebugEnabled()) {

Loading…
Cancel
Save