Replace Function<X, X> with UnaryOperator<X> in unstable modules #14892
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Replaces all occurrences of
Function<X, X>
with the more semantically appropriateUnaryOperator<X>
in non-stable modules throughout the codebase.Motivation
UnaryOperator<T>
is a specialization ofFunction<T, T>
that more clearly expresses the intent of operations that transform a value of the same type. UsingUnaryOperator
makes the code more readable and self-documenting.Changes
This PR updates the following areas:
Core Infrastructure
Function<Advice.WithCustomMapping, Advice.WithCustomMapping>
toUnaryOperator<Advice.WithCustomMapping>
in the javaagent extension API and all implementationsAdviceClassNameCollector
to useUnaryOperator
Instrumentation Modules
CompletionStageFunction
to implementUnaryOperator<Object>
Function<RestClient, RestClient>
toUnaryOperator<RestClient>
Function<Number, Number>
toUnaryOperator<Number>
UnaryOperator<Object>
UnaryOperator<Runnable>
for schedule hooksUnaryOperator<reactor.util.context.Context>
for context transformationsMainJarPathFinder
to useUnaryOperator<String>
for system property lookupsTest Updates
Updated corresponding test files to use
UnaryOperator
in type declarations and casts where appropriate.Scope
✅ Only modified unstable modules (no changes to stable APIs)
✅ All affected modules compile successfully
✅ No behavioral changes - purely a refactoring for code clarity
Fixes #[issue-number] (originally suggested in #13776 (comment))
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
maven.restlet.talend.com
scans-in.gradle.com
/usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.xml/javax.xml.namespace=ALL-UNNAMED --add-opens=java.base/java.time=ALL-UNNAMED -XX:MaxMetaspaceSize=512m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -cp /home/REDACTED/.gradle/wrapper/dists/gradle-9.1.0-bin/9agqghryom9wkf8r80qlhnts3/gradle-9.1.0/lib/gradle-daemon-main-9.1.0.jar -javaagent:/home/REDACTED/.gradle/wrapper/dists/gradle-9.1.0-bin/9agqghryom9wkf8r80qlhnts3/gradle-9.1.0/lib/agents/gradle-instrumentation-agent-9.1.0.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 9.1.0
(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.