From a1a4e735d746a75bed29c3dd7c429d8ef8b81e73 Mon Sep 17 00:00:00 2001 From: Georgios Andrianakis Date: Wed, 20 Apr 2022 13:13:19 +0300 Subject: [PATCH] Prevent unnecessary parameter array allocations We only need to actually allocate the object array that will hold the Resource method parameters if that method actually has parameters --- .../reactive/server/core/ResteasyReactiveRequestContext.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/ResteasyReactiveRequestContext.java b/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/ResteasyReactiveRequestContext.java index 0ad1702e76ef0..5a071585efe96 100644 --- a/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/ResteasyReactiveRequestContext.java +++ b/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/ResteasyReactiveRequestContext.java @@ -175,7 +175,7 @@ public void restart(RuntimeResource target) { public void restart(RuntimeResource target, boolean setLocatorTarget) { this.handlers = target.getHandlerChain(); position = 0; - parameters = new Object[target.getParameterTypes().length]; + parameters = target.getParameterTypes().length == 0 ? EMPTY_ARRAY : new Object[target.getParameterTypes().length]; if (setLocatorTarget) { previousResource = new PreviousResource(this.target, pathParamValues, previousResource); } @@ -646,7 +646,7 @@ protected void requestScopeDeactivated() { @Override protected void restarted(boolean keepTarget) { - parameters = new Object[0]; + parameters = EMPTY_ARRAY; if (!keepTarget) { target = null; }