diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/ConstructorResolver.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/ConstructorResolver.java index 4665615a18..ed9c16bebd 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/ConstructorResolver.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/ConstructorResolver.java @@ -288,7 +288,7 @@ class ConstructorResolver { } private Object instantiate( - String beanName, RootBeanDefinition mbd, Constructor constructorToUse, Object[] argsToUse) { + String beanName, RootBeanDefinition mbd, Constructor constructorToUse, Object[] argsToUse) { try { InstantiationStrategy strategy = this.beanFactory.getInstantiationStrategy(); @@ -933,7 +933,7 @@ class ConstructorResolver { // Decrease raw weight by 1024 to prefer it over equal converted weight. int typeDiffWeight = MethodInvoker.getTypeDifferenceWeight(paramTypes, this.arguments); int rawTypeDiffWeight = MethodInvoker.getTypeDifferenceWeight(paramTypes, this.rawArguments) - 1024; - return (rawTypeDiffWeight < typeDiffWeight ? rawTypeDiffWeight : typeDiffWeight); + return Math.min(rawTypeDiffWeight, typeDiffWeight); } public int getAssignabilityWeight(Class[] paramTypes) { diff --git a/spring-jms/src/main/java/org/springframework/jms/listener/DefaultMessageListenerContainer.java b/spring-jms/src/main/java/org/springframework/jms/listener/DefaultMessageListenerContainer.java index 8b58ceac81..b9532b04a8 100644 --- a/spring-jms/src/main/java/org/springframework/jms/listener/DefaultMessageListenerContainer.java +++ b/spring-jms/src/main/java/org/springframework/jms/listener/DefaultMessageListenerContainer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -383,8 +383,7 @@ public class DefaultMessageListenerContainer extends AbstractPollingMessageListe public void setMaxConcurrentConsumers(int maxConcurrentConsumers) { Assert.isTrue(maxConcurrentConsumers > 0, "'maxConcurrentConsumers' value must be at least 1 (one)"); synchronized (this.lifecycleMonitor) { - this.maxConcurrentConsumers = - (maxConcurrentConsumers > this.concurrentConsumers ? maxConcurrentConsumers : this.concurrentConsumers); + this.maxConcurrentConsumers = Math.max(maxConcurrentConsumers, this.concurrentConsumers); } } diff --git a/spring-test/src/main/java/org/springframework/test/annotation/TestAnnotationUtils.java b/spring-test/src/main/java/org/springframework/test/annotation/TestAnnotationUtils.java index f15b06cb3b..dd0c41f59b 100644 --- a/spring-test/src/main/java/org/springframework/test/annotation/TestAnnotationUtils.java +++ b/spring-test/src/main/java/org/springframework/test/annotation/TestAnnotationUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -37,10 +37,7 @@ public abstract class TestAnnotationUtils { */ public static long getTimeout(Method method) { Timed timed = AnnotatedElementUtils.findMergedAnnotation(method, Timed.class); - if (timed == null) { - return 0; - } - return Math.max(0, timed.millis()); + return (timed == null ? 0 : Math.max(0, timed.millis())); } /** diff --git a/spring-test/src/main/java/org/springframework/test/context/junit4/SpringJUnit4ClassRunner.java b/spring-test/src/main/java/org/springframework/test/context/junit4/SpringJUnit4ClassRunner.java index 0294700ac2..f7031e9e5c 100644 --- a/spring-test/src/main/java/org/springframework/test/context/junit4/SpringJUnit4ClassRunner.java +++ b/spring-test/src/main/java/org/springframework/test/context/junit4/SpringJUnit4ClassRunner.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -400,7 +400,7 @@ public class SpringJUnit4ClassRunner extends BlockJUnit4ClassRunner { */ protected long getJUnitTimeout(FrameworkMethod frameworkMethod) { Test test = frameworkMethod.getAnnotation(Test.class); - return (test != null && test.timeout() > 0 ? test.timeout() : 0); + return (test == null ? 0 : Math.max(0, test.timeout())); } /** diff --git a/spring-web/src/main/java/org/springframework/web/multipart/commons/CommonsMultipartFile.java b/spring-web/src/main/java/org/springframework/web/multipart/commons/CommonsMultipartFile.java index 69a1923832..05bfeddcbc 100644 --- a/spring-web/src/main/java/org/springframework/web/multipart/commons/CommonsMultipartFile.java +++ b/spring-web/src/main/java/org/springframework/web/multipart/commons/CommonsMultipartFile.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -109,7 +109,7 @@ public class CommonsMultipartFile implements MultipartFile, Serializable { // Check for Windows-style path int winSep = filename.lastIndexOf('\\'); // Cut off at latest possible point - int pos = (winSep > unixSep ? winSep : unixSep); + int pos = Math.max(winSep, unixSep); if (pos != -1) { // Any sort of path separator found... return filename.substring(pos + 1);