aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From csie...@apache.org
Subject aries-jax-rs-whiteboard git commit: Fix extensions without name cause NPE
Date Mon, 06 Nov 2017 15:45:51 GMT
Repository: aries-jax-rs-whiteboard
Updated Branches:
  refs/heads/master b8248259c -> 9b7afe5ec


Fix extensions without name cause NPE

when requesting the DTO


Project: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/repo
Commit: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/commit/9b7afe5e
Tree: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/tree/9b7afe5e
Diff: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/diff/9b7afe5e

Branch: refs/heads/master
Commit: 9b7afe5ec3a7c8a4f8d52ed4167471cc441c5a62
Parents: b824825
Author: Carlos Sierra <csierra@apache.org>
Authored: Mon Nov 6 16:43:34 2017 +0100
Committer: Carlos Sierra <csierra@apache.org>
Committed: Mon Nov 6 16:44:52 2017 +0100

----------------------------------------------------------------------
 jax-rs.itests/src/main/java/test/JaxrsTest.java | 23 ++++++++++++++++++++
 .../internal/AriesJaxRSServiceRuntime.java      |  3 +--
 2 files changed, 24 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/9b7afe5e/jax-rs.itests/src/main/java/test/JaxrsTest.java
----------------------------------------------------------------------
diff --git a/jax-rs.itests/src/main/java/test/JaxrsTest.java b/jax-rs.itests/src/main/java/test/JaxrsTest.java
index 59f6b1c..1cdee14 100644
--- a/jax-rs.itests/src/main/java/test/JaxrsTest.java
+++ b/jax-rs.itests/src/main/java/test/JaxrsTest.java
@@ -782,6 +782,29 @@ public class JaxrsTest extends TestHelper {
         filterRegistration.unregister();
     }
 
+    @Test
+    public void testExtensionWithoutAName() {
+        Dictionary<String, Object> properties = new Hashtable<>();
+
+        properties.put(JAX_RS_EXTENSION, true);
+
+        ServiceRegistration<ContainerResponseFilter> registration =
+            bundleContext.registerService(
+                ContainerResponseFilter.class, new TestFilter(), properties);
+
+        try {
+            RuntimeDTO runtimeDTO = _runtime.getRuntimeDTO();
+
+            assertEquals(
+                (long)registration.getReference().getProperty("service.id"),
+                runtimeDTO.defaultApplication.extensionDTOs[0].serviceId);
+        }
+        finally {
+            registration.unregister();
+        }
+
+    }
+
     @Ignore
     @Test
     public void testFeatureExtension() {

http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/9b7afe5e/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/AriesJaxRSServiceRuntime.java
----------------------------------------------------------------------
diff --git a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/AriesJaxRSServiceRuntime.java
b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/AriesJaxRSServiceRuntime.java
index be3fa1a..b8a0e5a 100644
--- a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/AriesJaxRSServiceRuntime.java
+++ b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/AriesJaxRSServiceRuntime.java
@@ -551,8 +551,7 @@ public class AriesJaxRSServiceRuntime implements JaxRSServiceRuntime {
     private static ExtensionDTO populateExtensionDTO(
         ExtensionDTO extensionDTO, CachingServiceReference<?> serviceReference) {
 
-        extensionDTO.name = serviceReference.getProperty(JAX_RS_NAME).
-            toString();
+        extensionDTO.name = getApplicationName(serviceReference::getProperty);
         extensionDTO.serviceId = (Long)serviceReference.getProperty(
             "service.id");
         extensionDTO.extensionTypes =


Mime
View raw message