Skip to content

Commit

Permalink
Merge pull request #31913 from quaff
Browse files Browse the repository at this point in the history
* pr/31913:
  Update copyright year of changed files
  Cleanup kotlin sources

Closes gh-31913
  • Loading branch information
snicoll committed Dec 28, 2023
2 parents 28a7b61 + 7e5afc8 commit c3b5f5b
Show file tree
Hide file tree
Showing 10 changed files with 78 additions and 64 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* 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.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.springframework.aop.framework.autoproxy

import kotlinx.coroutines.delay
Expand Down Expand Up @@ -94,12 +110,12 @@ class AspectJAutoProxyInterceptorKotlinIntegrationTests(
open class Echo {

open fun echo(value: String): String {
return value;
return value
}

open suspend fun suspendingEcho(value: String): String {
delay(1)
return value;
return value
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class AopUtilsKotlinTests {
@Suppress("unused")
suspend fun suspendingFunction(value: String): String {
delay(1)
return value;
return value
}

}
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -16,7 +16,7 @@

package org.springframework.beans

import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeUnit

import org.openjdk.jmh.annotations.Benchmark
import org.openjdk.jmh.annotations.BenchmarkMode
Expand All @@ -30,22 +30,22 @@ import org.openjdk.jmh.annotations.State
@OutputTimeUnit(TimeUnit.NANOSECONDS)
open class KotlinBeanUtilsBenchmark {

private val noArgConstructor = TestClass1::class.java.getDeclaredConstructor()
private val constructor = TestClass2::class.java.getDeclaredConstructor(Int::class.java, String::class.java)
private val noArgConstructor = TestClass1::class.java.getDeclaredConstructor()
private val constructor = TestClass2::class.java.getDeclaredConstructor(Int::class.java, String::class.java)

@Benchmark
fun emptyConstructor(): Any {
@Benchmark
fun emptyConstructor(): Any {
return BeanUtils.instantiateClass(noArgConstructor)
}
}

@Benchmark
fun nonEmptyConstructor(): Any {
@Benchmark
fun nonEmptyConstructor(): Any {
return BeanUtils.instantiateClass(constructor, 1, "str")
}
}

class TestClass1()
class TestClass1

@Suppress("UNUSED_PARAMETER")
class TestClass2(int: Int, string: String)
@Suppress("UNUSED_PARAMETER")
class TestClass2(int: Int, string: String)
}

Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
* 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.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
Expand Down Expand Up @@ -35,7 +35,7 @@ inline fun <reified T> JdbcOperations.queryForObject(sql: String): T =
* @since 5.0
*/
inline fun <reified T> JdbcOperations.queryForObject(sql: String, vararg args: Any, crossinline function: (ResultSet, Int) -> T): T =
queryForObject(sql, RowMapper { resultSet, i -> function(resultSet, i) }, *args) as T
queryForObject(sql, { resultSet, i -> function(resultSet, i) }, *args) as T

/**
* Extension for [JdbcOperations.queryForObject] providing a
Expand Down Expand Up @@ -113,7 +113,7 @@ inline fun <reified T> JdbcOperations.query(sql: String, vararg args: Any,
* @since 5.0
*/
fun JdbcOperations.query(sql: String, vararg args: Any, function: (ResultSet) -> Unit): Unit =
query(sql, RowCallbackHandler { function(it) }, *args)
query(sql, { function(it) }, *args)

/**
* Extensions for [JdbcOperations.query] providing a RowMapper-like function variant:
Expand All @@ -123,4 +123,4 @@ fun JdbcOperations.query(sql: String, vararg args: Any, function: (ResultSet) ->
* @since 5.0
*/
fun <T> JdbcOperations.query(sql: String, vararg args: Any, function: (ResultSet, Int) -> T): List<T> =
query(sql, RowMapper { rs, i -> function(rs, i) }, *args)
query(sql, { rs, i -> function(rs, i) }, *args)
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -174,7 +174,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs
* @since 5.3
*/
fun GET(predicate: RequestPredicate, f: (ServerRequest) -> Mono<out ServerResponse>) {
builder.GET(predicate, HandlerFunction<ServerResponse> { f(it).cast(ServerResponse::class.java) })
builder.GET(predicate, { f(it).cast(ServerResponse::class.java) })
}

/**
Expand All @@ -185,7 +185,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs
* @since 5.2
*/
fun GET(pattern: String, predicate: RequestPredicate, f: (ServerRequest) -> Mono<out ServerResponse>) {
builder.GET(pattern, predicate, HandlerFunction<ServerResponse> { f(it).cast(ServerResponse::class.java) })
builder.GET(pattern, predicate, HandlerFunction { f(it).cast(ServerResponse::class.java) })
}

/**
Expand Down Expand Up @@ -219,7 +219,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs
* @since 5.3
*/
fun HEAD(predicate: RequestPredicate, f: (ServerRequest) -> Mono<out ServerResponse>) {
builder.HEAD(predicate, HandlerFunction<ServerResponse> { f(it).cast(ServerResponse::class.java) })
builder.HEAD(predicate, HandlerFunction { f(it).cast(ServerResponse::class.java) })
}

/**
Expand All @@ -230,7 +230,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs
* @since 5.2
*/
fun HEAD(pattern: String, predicate: RequestPredicate, f: (ServerRequest) -> Mono<out ServerResponse>) {
builder.HEAD(pattern, predicate, HandlerFunction<ServerResponse> { f(it).cast(ServerResponse::class.java) })
builder.HEAD(pattern, predicate, HandlerFunction { f(it).cast(ServerResponse::class.java) })
}

/**
Expand Down Expand Up @@ -264,7 +264,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs
* @since 5.3
*/
fun POST(predicate: RequestPredicate, f: (ServerRequest) -> Mono<out ServerResponse>) {
builder.POST(predicate, HandlerFunction<ServerResponse> { f(it).cast(ServerResponse::class.java) })
builder.POST(predicate, HandlerFunction { f(it).cast(ServerResponse::class.java) })
}

/**
Expand All @@ -275,7 +275,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs
* @since 5.2
*/
fun POST(pattern: String, predicate: RequestPredicate, f: (ServerRequest) -> Mono<out ServerResponse>) {
builder.POST(pattern, predicate, HandlerFunction<ServerResponse> { f(it).cast(ServerResponse::class.java) })
builder.POST(pattern, predicate, HandlerFunction { f(it).cast(ServerResponse::class.java) })
}

/**
Expand Down Expand Up @@ -309,7 +309,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs
* @since 5.3
*/
fun PUT(predicate: RequestPredicate, f: (ServerRequest) -> Mono<out ServerResponse>) {
builder.PUT(predicate, HandlerFunction<ServerResponse> { f(it).cast(ServerResponse::class.java) })
builder.PUT(predicate, HandlerFunction { f(it).cast(ServerResponse::class.java) })
}

/**
Expand All @@ -320,7 +320,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs
* @since 5.2
*/
fun PUT(pattern: String, predicate: RequestPredicate, f: (ServerRequest) -> Mono<out ServerResponse>) {
builder.PUT(pattern, predicate, HandlerFunction<ServerResponse> { f(it).cast(ServerResponse::class.java) })
builder.PUT(pattern, predicate, HandlerFunction { f(it).cast(ServerResponse::class.java) })
}

/**
Expand Down Expand Up @@ -354,7 +354,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs
* @since 5.3
*/
fun PATCH(predicate: RequestPredicate, f: (ServerRequest) -> Mono<out ServerResponse>) {
builder.PATCH(predicate, HandlerFunction<ServerResponse> { f(it).cast(ServerResponse::class.java) })
builder.PATCH(predicate, HandlerFunction { f(it).cast(ServerResponse::class.java) })
}

/**
Expand All @@ -365,7 +365,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs
* @since 5.2
*/
fun PATCH(pattern: String, predicate: RequestPredicate, f: (ServerRequest) -> Mono<out ServerResponse>) {
builder.PATCH(pattern, predicate, HandlerFunction<ServerResponse> { f(it).cast(ServerResponse::class.java) })
builder.PATCH(pattern, predicate, HandlerFunction { f(it).cast(ServerResponse::class.java) })
}

/**
Expand Down Expand Up @@ -401,7 +401,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs
* @since 5.3
*/
fun DELETE(predicate: RequestPredicate, f: (ServerRequest) -> Mono<out ServerResponse>) {
builder.DELETE(predicate, HandlerFunction<ServerResponse> { f(it).cast(ServerResponse::class.java) })
builder.DELETE(predicate, HandlerFunction { f(it).cast(ServerResponse::class.java) })
}

/**
Expand All @@ -412,7 +412,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs
* @since 5.2
*/
fun DELETE(pattern: String, predicate: RequestPredicate, f: (ServerRequest) -> Mono<out ServerResponse>) {
builder.DELETE(pattern, predicate, HandlerFunction<ServerResponse> { f(it).cast(ServerResponse::class.java) })
builder.DELETE(pattern, predicate, HandlerFunction { f(it).cast(ServerResponse::class.java) })
}

/**
Expand Down Expand Up @@ -448,7 +448,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs
* @since 5.3
*/
fun OPTIONS(predicate: RequestPredicate, f: (ServerRequest) -> Mono<out ServerResponse>) {
builder.OPTIONS(predicate, HandlerFunction<ServerResponse> { f(it).cast(ServerResponse::class.java) })
builder.OPTIONS(predicate, HandlerFunction { f(it).cast(ServerResponse::class.java) })
}

/**
Expand All @@ -459,7 +459,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs
* @since 5.2
*/
fun OPTIONS(pattern: String, predicate: RequestPredicate, f: (ServerRequest) -> Mono<out ServerResponse>) {
builder.OPTIONS(pattern, predicate, HandlerFunction<ServerResponse> { f(it).cast(ServerResponse::class.java) })
builder.OPTIONS(pattern, predicate, HandlerFunction { f(it).cast(ServerResponse::class.java) })
}

/**
Expand All @@ -476,7 +476,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs
* @see RouterFunctions.route
*/
fun accept(mediaType: MediaType, f: (ServerRequest) -> Mono<out ServerResponse>) {
builder.add(RouterFunctions.route(RequestPredicates.accept(mediaType), HandlerFunction<ServerResponse> { f(it).cast(ServerResponse::class.java) }))
builder.add(RouterFunctions.route(RequestPredicates.accept(mediaType), HandlerFunction { f(it).cast(ServerResponse::class.java) }))
}

/**
Expand All @@ -493,7 +493,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs
* @see RouterFunctions.route
*/
fun contentType(mediaTypes: MediaType, f: (ServerRequest) -> Mono<out ServerResponse>) {
builder.add(RouterFunctions.route(RequestPredicates.contentType(mediaTypes), HandlerFunction<ServerResponse> { f(it).cast(ServerResponse::class.java) }))
builder.add(RouterFunctions.route(RequestPredicates.contentType(mediaTypes), HandlerFunction { f(it).cast(ServerResponse::class.java) }))
}

/**
Expand All @@ -510,7 +510,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs
* @see RouterFunctions.route
*/
fun headers(headersPredicate: (ServerRequest.Headers) -> Boolean, f: (ServerRequest) -> Mono<out ServerResponse>) {
builder.add(RouterFunctions.route(RequestPredicates.headers(headersPredicate), HandlerFunction<ServerResponse> { f(it).cast(ServerResponse::class.java) }))
builder.add(RouterFunctions.route(RequestPredicates.headers(headersPredicate), HandlerFunction { f(it).cast(ServerResponse::class.java) }))
}

/**
Expand All @@ -526,7 +526,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs
* @see RouterFunctions.route
*/
fun method(httpMethod: HttpMethod, f: (ServerRequest) -> Mono<out ServerResponse>) {
builder.add(RouterFunctions.route(RequestPredicates.method(httpMethod), HandlerFunction<ServerResponse> { f(it).cast(ServerResponse::class.java) }))
builder.add(RouterFunctions.route(RequestPredicates.method(httpMethod), HandlerFunction { f(it).cast(ServerResponse::class.java) }))
}

/**
Expand All @@ -541,7 +541,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs
* @see RouterFunctions.route
*/
fun path(pattern: String, f: (ServerRequest) -> Mono<out ServerResponse>) {
builder.add(RouterFunctions.route(RequestPredicates.path(pattern), HandlerFunction<ServerResponse> { f(it).cast(ServerResponse::class.java) }))
builder.add(RouterFunctions.route(RequestPredicates.path(pattern), HandlerFunction { f(it).cast(ServerResponse::class.java) }))
}

/**
Expand All @@ -555,7 +555,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs
* @see RouterFunctions.route
*/
fun pathExtension(extension: String, f: (ServerRequest) -> Mono<out ServerResponse>) {
builder.add(RouterFunctions.route(RequestPredicates.pathExtension(extension), HandlerFunction<ServerResponse> { f(it).cast(ServerResponse::class.java) }))
builder.add(RouterFunctions.route(RequestPredicates.pathExtension(extension), HandlerFunction { f(it).cast(ServerResponse::class.java) }))
}

/**
Expand All @@ -570,7 +570,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs
* @see RouterFunctions.route
*/
fun pathExtension(predicate: (String) -> Boolean, f: (ServerRequest) -> Mono<out ServerResponse>) {
builder.add(RouterFunctions.route(RequestPredicates.pathExtension(predicate), HandlerFunction<ServerResponse> { f(it).cast(ServerResponse::class.java) }))
builder.add(RouterFunctions.route(RequestPredicates.pathExtension(predicate), HandlerFunction { f(it).cast(ServerResponse::class.java) }))
}

/**
Expand All @@ -586,7 +586,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs
* @see RouterFunctions.route
*/
fun queryParam(name: String, predicate: (String) -> Boolean, f: (ServerRequest) -> Mono<out ServerResponse>) {
builder.add(RouterFunctions.route(RequestPredicates.queryParam(name, predicate), HandlerFunction<ServerResponse> { f(it).cast(ServerResponse::class.java) }))
builder.add(RouterFunctions.route(RequestPredicates.queryParam(name, predicate), HandlerFunction { f(it).cast(ServerResponse::class.java) }))
}

/**
Expand All @@ -605,7 +605,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs
* @see RouterFunctions.route
*/
operator fun RequestPredicate.invoke(f: (ServerRequest) -> Mono<out ServerResponse>) {
builder.add(RouterFunctions.route(this, HandlerFunction<ServerResponse> { f(it).cast(ServerResponse::class.java) }))
builder.add(RouterFunctions.route(this, HandlerFunction { f(it).cast(ServerResponse::class.java) }))
}

/**
Expand All @@ -614,7 +614,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs
* @see RouterFunctions.route
*/
operator fun String.invoke(f: (ServerRequest) -> Mono<out ServerResponse>) {
builder.add(RouterFunctions.route(RequestPredicates.path(this), HandlerFunction<ServerResponse> { f(it).cast(ServerResponse::class.java) }))
builder.add(RouterFunctions.route(RequestPredicates.path(this), HandlerFunction { f(it).cast(ServerResponse::class.java) }))
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,8 @@ class CoRouterFunctionDslTests {
listOf(mapOf("foo" to "bar"), mapOf("foo" to "n1")),
listOf(mapOf("baz" to "qux"), mapOf("foo" to "n1")),
listOf(mapOf("foo" to "n3"), mapOf("foo" to "n2"), mapOf("foo" to "n1"))
);
assertThat(visitor.visitCount()).isEqualTo(7);
)
assertThat(visitor.visitCount()).isEqualTo(7)
}

private fun sampleRouter() = coRouter {
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -27,7 +27,6 @@ import org.springframework.http.MediaType.*
import org.springframework.web.reactive.function.server.support.ServerRequestWrapper
import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest.*
import org.springframework.web.testfixture.server.MockServerWebExchange
import org.springframework.web.reactive.function.server.AttributesTestVisitor
import reactor.core.publisher.Mono
import reactor.test.StepVerifier
import java.security.Principal
Expand Down Expand Up @@ -167,8 +166,8 @@ class RouterFunctionDslTests {
listOf(mapOf("foo" to "bar"), mapOf("foo" to "n1")),
listOf(mapOf("baz" to "qux"), mapOf("foo" to "n1")),
listOf(mapOf("foo" to "n3"), mapOf("foo" to "n2"), mapOf("foo" to "n1"))
);
assertThat(visitor.visitCount()).isEqualTo(7);
)
assertThat(visitor.visitCount()).isEqualTo(7)
}

@Test
Expand Down
Loading

0 comments on commit c3b5f5b

Please sign in to comment.