You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by co...@apache.org on 2018/08/14 11:32:28 UTC

[cxf] 02/04: NPE when annotations bundle found but not active

This is an automated email from the ASF dual-hosted git repository.

coheigea pushed a commit to branch 3.2.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit bd0cb45b4a40bbcc9b66c43411ad5d5cadccf16c
Author: Rabea Gransberger <rg...@users.noreply.github.com>
AuthorDate: Thu Aug 9 16:25:56 2018 +0200

    NPE when annotations bundle found but not active
    
    bundle.getBundleContext() will give an NPE (in Equinox) if the bundle can be found but is not active.
    Would also be good to at least log the exception in debug mode to point to a possible problem.
    
    (cherry picked from commit 5ae9b0a5b928b49fc2a4b3fb8dd9b68dca640eb7)
---
 .../main/java/org/apache/cxf/jaxrs/swagger/OsgiSwaggerUiResolver.java  | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/rt/rs/description-swagger-ui/src/main/java/org/apache/cxf/jaxrs/swagger/OsgiSwaggerUiResolver.java b/rt/rs/description-swagger-ui/src/main/java/org/apache/cxf/jaxrs/swagger/OsgiSwaggerUiResolver.java
index 8374f8c..0b94ad3 100644
--- a/rt/rs/description-swagger-ui/src/main/java/org/apache/cxf/jaxrs/swagger/OsgiSwaggerUiResolver.java
+++ b/rt/rs/description-swagger-ui/src/main/java/org/apache/cxf/jaxrs/swagger/OsgiSwaggerUiResolver.java
@@ -47,6 +47,9 @@ public class OsgiSwaggerUiResolver extends SwaggerUiResolver {
             if (bundle == null) {
                 return null;
             }
+            if (bundle.getState() != Bundle.ACTIVE) {
+				bundle.start();
+			}
             String[] locations = swaggerUiMavenGroupAndArtifact == null ? DEFAULT_LOCATIONS
                 : new String[]{"mvn:" + swaggerUiMavenGroupAndArtifact + "/",
                                "wrap:mvn:" + swaggerUiMavenGroupAndArtifact + "/"};