Skip to content

Commit 4bee348

Browse files
authored
Merge pull request #31388 from geoand/rr-polish
Apply various polishing operations to RESTEasy Reactive source code
2 parents 608c1db + d237ccd commit 4bee348

File tree

37 files changed

+61
-68
lines changed

37 files changed

+61
-68
lines changed

extensions/resteasy-reactive/quarkus-resteasy-reactive-common/deployment/src/main/java/io/quarkus/resteasy/reactive/common/deployment/VetoingAnnotationTransformer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* then we need to make sure that Arc doesn't create a bean for it automatically (as it will fail validation because
1414
* there is no way to pass the parameter).
1515
* For these resources we add {@link jakarta.enterprise.inject.Vetoed}, and we generate custom CDI producers under the hood
16-
* in {@link CustomResourceProducersGenerator#generate}.
16+
* in {@code io.quarkus.resteasy.reactive.server.deployment.CustomResourceProducersGenerator#generate}.
1717
*/
1818
public class VetoingAnnotationTransformer implements AnnotationsTransformer {
1919

extensions/resteasy-reactive/quarkus-resteasy-reactive-common/runtime/src/main/java/io/quarkus/resteasy/reactive/common/runtime/JaxRsSecurityConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public interface JaxRsSecurityConfig {
2323
* If no security annotations are affecting a method then they will default to requiring these roles,
2424
* (equivalent to adding an @RolesAllowed annotation with the roles to every endpoint class).
2525
*
26-
* The role of '**' means any authenticated user, which is equivalent to the {@link io.quarkus.security.Authenticated}
26+
* The role of '**' means any authenticated user, which is equivalent to the {@code io.quarkus.security.Authenticated}
2727
* annotation.
2828
*/
2929
Optional<List<String>> defaultRolesAllowed();

extensions/resteasy-reactive/quarkus-resteasy-reactive-common/runtime/src/main/java/io/quarkus/resteasy/reactive/common/runtime/ResteasyReactiveCommonRecorder.java

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package io.quarkus.resteasy.reactive.common.runtime;
22

3-
import java.util.Collections;
4-
import java.util.HashMap;
53
import java.util.Map;
64

75
import org.jboss.resteasy.reactive.common.core.Serialisers;
@@ -14,19 +12,15 @@
1412

1513
@Recorder
1614
public class ResteasyReactiveCommonRecorder {
17-
private static final Map<String, Class<?>> primitiveTypes;
18-
static {
19-
Map<String, Class<?>> prims = new HashMap<>();
20-
prims.put(byte.class.getName(), byte.class);
21-
prims.put(boolean.class.getName(), boolean.class);
22-
prims.put(char.class.getName(), char.class);
23-
prims.put(short.class.getName(), short.class);
24-
prims.put(int.class.getName(), int.class);
25-
prims.put(float.class.getName(), float.class);
26-
prims.put(double.class.getName(), double.class);
27-
prims.put(long.class.getName(), long.class);
28-
primitiveTypes = Collections.unmodifiableMap(prims);
29-
}
15+
private static final Map<String, Class<?>> primitiveTypes = Map.of(
16+
byte.class.getName(), byte.class,
17+
boolean.class.getName(), boolean.class,
18+
char.class.getName(), char.class,
19+
short.class.getName(), short.class,
20+
int.class.getName(), int.class,
21+
float.class.getName(), float.class,
22+
double.class.getName(), double.class,
23+
long.class.getName(), long.class);
3024

3125
public <T> BeanFactory<T> factory(String targetClass, BeanContainer beanContainer) {
3226
return new ArcBeanFactory<>(loadClass(targetClass),

extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin/deployment/src/main/java/io/quarkus/resteasy/reactive/kotlin/deployment/KotlinCoroutineIntegrationProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public boolean isMethodSignatureAsync(MethodInfo info) {
125125
* This method generates the same invocation code as for the standard invoker but also passes along the implicit
126126
* {@code Continuation} argument provided by kotlinc and the coroutines library.
127127
*
128-
* @see io.quarkus.resteasy.reactive.server.deployment.QuarkusInvokerFactory#create(ResourceMethod, ClassInfo, MethodInfo)
128+
* See: io.quarkus.resteasy.reactive.server.deployment.QuarkusInvokerFactory#create(ResourceMethod, ClassInfo, MethodInfo)
129129
*/
130130
private Supplier<EndpointInvoker> createCoroutineInvoker(ClassInfo currentClassInfo,
131131
MethodInfo info, BuildProducer<GeneratedClassBuildItem> generatedClassBuildItemBuildProducer,

extensions/resteasy-reactive/quarkus-resteasy-reactive/runtime/src/main/java/io/quarkus/resteasy/reactive/server/runtime/ResteasyReactiveRuntimeRecorder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public RuntimeConfiguration get() {
4949
};
5050
}
5151

52-
@SuppressWarnings({ "unchecked", "rawtypes" })
52+
@SuppressWarnings({ "unchecked", "rawtypes", "ForLoopReplaceableByForEach" })
5353
public void configureHandlers(RuntimeValue<Deployment> deployment, Map<Class<?>, Supplier<?>> runtimeConfigMap) {
5454
List<GenericRuntimeConfigurableServerRestHandler<?>> runtimeConfigurableServerRestHandlers = deployment.getValue()
5555
.getRuntimeConfigurableServerRestHandlers();

extensions/resteasy-reactive/rest-client-reactive/runtime/src/main/java/io/quarkus/rest/client/reactive/runtime/ResteasyReactiveResponseRedirectHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ default URI handle(Response response) {
1515

1616
@Override
1717
default RedirectHandler getContext(Class<?> aClass) {
18-
return response -> handle(response);
18+
return this::handle;
1919
}
2020
}

independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/HandlerChain.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import org.jboss.resteasy.reactive.client.spi.MultipartResponseData;
2121
import org.jboss.resteasy.reactive.common.jaxrs.ConfigurationImpl;
2222

23+
@SuppressWarnings("ForLoopReplaceableByForEach")
2324
class HandlerChain {
2425

2526
private static final ClientRestHandler[] EMPTY_REST_HANDLERS = new ClientRestHandler[0];

independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/MultiInvoker.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -159,18 +159,12 @@ private <R> void registerForSse(MultiRequest<? super R> multiRequest,
159159
SseEventSourceImpl sseSource = new SseEventSourceImpl(invocationBuilder.getTarget(),
160160
invocationBuilder, Integer.MAX_VALUE, TimeUnit.SECONDS);
161161

162-
multiRequest.onCancel(() -> {
163-
sseSource.close();
164-
});
162+
multiRequest.onCancel(sseSource::close);
165163
sseSource.register(event -> {
166164
// DO NOT pass the response mime type because it's SSE: let the event pick between the X-SSE-Content-Type header or
167165
// the content-type SSE field
168166
multiRequest.emit(event.readData(responseType));
169-
}, error -> {
170-
multiRequest.fail(error);
171-
}, () -> {
172-
multiRequest.complete();
173-
});
167+
}, multiRequest::fail, multiRequest::complete);
174168
// watch for user cancelling
175169
sseSource.registerAfterRequest(vertxResponse);
176170
}

independent-projects/resteasy-reactive/common/processor/src/main/java/org/jboss/resteasy/reactive/common/processor/EndpointIndexer.java

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@
8282
import java.nio.charset.StandardCharsets;
8383
import java.util.AbstractMap;
8484
import java.util.ArrayList;
85-
import java.util.Arrays;
8685
import java.util.Collection;
8786
import java.util.Collections;
8887
import java.util.HashMap;
@@ -135,22 +134,15 @@ public abstract class EndpointIndexer<T extends EndpointIndexer<T, PARAM, METHOD
135134

136135
public static final Map<String, String> primitiveTypes;
137136
private static final Map<DotName, Class<?>> supportedReaderJavaTypes;
137+
// spec
138138
// NOTE: sync with ContextProducer and ContextParamExtractor
139-
private static final Set<DotName> DEFAULT_CONTEXT_TYPES = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(
140-
// spec
141-
URI_INFO,
142-
HTTP_HEADERS,
143-
REQUEST,
144-
SECURITY_CONTEXT,
145-
PROVIDERS,
146-
RESOURCE_CONTEXT,
147-
CONFIGURATION,
148-
SSE,
139+
private static final Set<DotName> DEFAULT_CONTEXT_TYPES = Set.of(URI_INFO, HTTP_HEADERS, REQUEST, SECURITY_CONTEXT,
140+
PROVIDERS, RESOURCE_CONTEXT, CONFIGURATION, SSE,
149141
SSE_EVENT_SINK,
150142
// extras
151143
SERVER_REQUEST_CONTEXT,
152144
DotName.createSimple("org.jboss.resteasy.reactive.server.SimpleResourceInfo"), //TODO: fixme
153-
RESOURCE_INFO)));
145+
RESOURCE_INFO);
154146

155147
protected static final Set<DotName> SUPPORT_TEMPORAL_PARAMS = Set.of(INSTANT, LOCAL_DATE, LOCAL_TIME, LOCAL_DATE_TIME,
156148
OFFSET_TIME,

independent-projects/resteasy-reactive/common/processor/src/main/java/org/jboss/resteasy/reactive/common/processor/HashUtil.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import java.security.MessageDigest;
55
import java.security.NoSuchAlgorithmException;
66

7+
@SuppressWarnings("ForLoopReplaceableByForEach")
78
public final class HashUtil {
89

910
private HashUtil() {

0 commit comments

Comments
 (0)