-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure ParameterConverter is loaded from the TCCL
This is needed because otherwise dev-mode could break in some cases Fixes: #39777 Follows up on: #39691 (cherry picked from commit 91a2f52)
- Loading branch information
Showing
2 changed files
with
37 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
.../jboss/resteasy/reactive/server/core/parameters/converters/ParameterConverterSupport.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package org.jboss.resteasy.reactive.server.core.parameters.converters; | ||
|
||
/** | ||
* This class isn't used directly, it is however used by generated code meant to deal with {@link ParameterConverter}. | ||
*/ | ||
@SuppressWarnings("unused") | ||
public final class ParameterConverterSupport { | ||
|
||
private ParameterConverterSupport() { | ||
} | ||
|
||
/** | ||
* Normally the reflective instantiation would not be needed, and we could just instantiate normally, | ||
* however that could break dev-mode when the converters are in a different module and non-standard Maven | ||
* configuration is used (see <a href="https://github.com/quarkusio/quarkus/issues/39773#issuecomment-2030493539">this</a>) | ||
*/ | ||
public static ParameterConverter create(String className) { | ||
try { | ||
Class<?> clazz = Class.forName(className, true, Thread.currentThread().getContextClassLoader()); | ||
return (ParameterConverter) clazz.getConstructor().newInstance(); | ||
} catch (Exception e) { | ||
throw new RuntimeException("Unable to create instance of " + className, e); | ||
} | ||
} | ||
} |