Skip to content

Commit 4936a63

Browse files
committed
Polishing
1 parent e8ef93c commit 4936a63

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed

spring-context/src/main/java/org/springframework/jmx/export/assembler/InterfaceBasedMBeanInfoAssembler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

spring-core/src/main/java/org/springframework/core/MethodParameter.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -867,8 +867,8 @@ private static class KotlinDelegate {
867867

868868
/**
869869
* Check whether the specified {@link MethodParameter} represents a nullable Kotlin type,
870-
* an optional parameter (with a default value in the Kotlin declaration) or a {@code Continuation} parameter
871-
* used in suspending functions.
870+
* an optional parameter (with a default value in the Kotlin declaration) or a
871+
* {@code Continuation} parameter used in suspending functions.
872872
*/
873873
public static boolean isOptional(MethodParameter param) {
874874
Method method = param.getMethod();
@@ -880,16 +880,18 @@ public static boolean isOptional(MethodParameter param) {
880880
KFunction<?> function;
881881
Predicate<KParameter> predicate;
882882
if (method != null) {
883-
if (param.parameterType.getName().equals("kotlin.coroutines.Continuation")) {
883+
if (param.getParameterType().getName().equals("kotlin.coroutines.Continuation")) {
884884
return true;
885885
}
886886
function = ReflectJvmMapping.getKotlinFunction(method);
887887
predicate = p -> KParameter.Kind.VALUE.equals(p.getKind());
888888
}
889889
else {
890-
function = ReflectJvmMapping.getKotlinFunction(param.getConstructor());
891-
predicate = p -> KParameter.Kind.VALUE.equals(p.getKind()) ||
892-
KParameter.Kind.INSTANCE.equals(p.getKind());
890+
Constructor<?> ctor = param.getConstructor();
891+
Assert.state(ctor != null, "Neither method nor constructor found");
892+
function = ReflectJvmMapping.getKotlinFunction(ctor);
893+
predicate = p -> (KParameter.Kind.VALUE.equals(p.getKind()) ||
894+
KParameter.Kind.INSTANCE.equals(p.getKind()));
893895
}
894896
if (function != null) {
895897
int i = 0;

spring-web/src/main/java/org/springframework/http/server/DefaultPathContainer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -107,7 +107,7 @@ static PathContainer createFromUrlPath(String path, Options options) {
107107
}
108108
List<Element> elements = new ArrayList<>();
109109
int begin;
110-
if (path.length() > 0 && path.charAt(0) == separator) {
110+
if (path.charAt(0) == separator) {
111111
begin = 1;
112112
elements.add(separatorElement);
113113
}

spring-web/src/main/java/org/springframework/web/method/ControllerAdviceBean.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -149,7 +149,7 @@ public ControllerAdviceBean(String beanName, BeanFactory beanFactory, @Nullable
149149
public int getOrder() {
150150
if (this.order == null) {
151151
Object resolvedBean = null;
152-
if (this.beanOrName instanceof String) {
152+
if (this.beanFactory != null && this.beanOrName instanceof String) {
153153
String beanName = (String) this.beanOrName;
154154
String targetBeanName = ScopedProxyUtils.getTargetBeanName(beanName);
155155
boolean isScopedProxy = this.beanFactory.containsBean(targetBeanName);

0 commit comments

Comments
 (0)