Skip to content

Commit

Permalink
[RESTEASY-3507] Cast the created application object instead of the type.
Browse files Browse the repository at this point in the history
https://issues.redhat.com/browse/RESTEASY-3507
Signed-off-by: James R. Perkins <jperkins@redhat.com>
  • Loading branch information
jamezp committed May 20, 2024
1 parent 60f270a commit 2be12e8
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -380,18 +380,19 @@ public void merge(ResteasyDeployment other) {

public static Application createApplication(String applicationClass, Dispatcher dispatcher,
ResteasyProviderFactory providerFactory) {
Class<? extends Application> clazz = null;
Class<?> clazz = null;
try {
clazz = Thread.currentThread().getContextClassLoader().loadClass(applicationClass).asSubclass(Application.class);
clazz = Thread.currentThread().getContextClassLoader().loadClass(applicationClass);
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}

Application app = providerFactory.createProviderInstance(clazz);
Application app = (Application) providerFactory.createProviderInstance(clazz);
dispatcher.getDefaultContextObjects().put(Application.class, app);
ResteasyContext.pushContext(Application.class, app);
@SuppressWarnings("unchecked")
final ApplicationDescription applicationDescription = ApplicationDescription.Builder.of(app)
.type(clazz)
.type((Class<? extends Application>) clazz)
.build();
dispatcher.getDefaultContextObjects().put(ApplicationDescription.class, applicationDescription);
ResteasyContext.pushContext(ApplicationDescription.class, applicationDescription);
Expand Down

0 comments on commit 2be12e8

Please sign in to comment.