felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject svn commit: r1750642 - in /felix/trunk/converter/src: main/java/org/apache/felix/converter/impl/ConvertingImpl.java test/java/org/apache/felix/converter/impl/ConverterServiceTest.java
Date Wed, 29 Jun 2016 13:59:27 GMT
Author: davidb
Date: Wed Jun 29 13:59:27 2016
New Revision: 1750642

URL: http://svn.apache.org/viewvc?rev=1750642&view=rev
Log:
Felix Converter Service: Fix bug in collection handling.

Modified:
    felix/trunk/converter/src/main/java/org/apache/felix/converter/impl/ConvertingImpl.java
    felix/trunk/converter/src/test/java/org/apache/felix/converter/impl/ConverterServiceTest.java

Modified: felix/trunk/converter/src/main/java/org/apache/felix/converter/impl/ConvertingImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/src/main/java/org/apache/felix/converter/impl/ConvertingImpl.java?rev=1750642&r1=1750641&r2=1750642&view=diff
==============================================================================
--- felix/trunk/converter/src/main/java/org/apache/felix/converter/impl/ConvertingImpl.java
(original)
+++ felix/trunk/converter/src/main/java/org/apache/felix/converter/impl/ConvertingImpl.java
Wed Jun 29 13:59:27 2016
@@ -124,7 +124,7 @@ public class ConvertingImpl implements C
         Class<?> targetCls = primitiveToBoxed(cls);
 
         if (!Map.class.isAssignableFrom(targetCls) &&
-                !Collections.class.isAssignableFrom(targetCls) &&
+                !Collection.class.isAssignableFrom(targetCls) &&
                 !targetCls.isArray()) {
             // For maps and collections we always want copies returned
             if (targetCls.isAssignableFrom(object.getClass()))

Modified: felix/trunk/converter/src/test/java/org/apache/felix/converter/impl/ConverterServiceTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/src/test/java/org/apache/felix/converter/impl/ConverterServiceTest.java?rev=1750642&r1=1750641&r2=1750642&view=diff
==============================================================================
--- felix/trunk/converter/src/test/java/org/apache/felix/converter/impl/ConverterServiceTest.java
(original)
+++ felix/trunk/converter/src/test/java/org/apache/felix/converter/impl/ConverterServiceTest.java
Wed Jun 29 13:59:27 2016
@@ -256,6 +256,19 @@ public class ConverterServiceTest {
     }
 
     @Test
+    public void testLongCollectionConversion() {
+        long[] l = converter.convert(Long.MAX_VALUE).to(long[].class);
+        assertArrayEquals(new long[] {Long.MAX_VALUE}, l);
+        Long[] l2 = converter.convert(Long.MAX_VALUE).to(Long[].class);
+        assertArrayEquals(new Long[] {Long.MAX_VALUE}, l2);
+        List<Long> ll = converter.convert(new long[] {Long.MIN_VALUE, Long.MAX_VALUE}).to(new
TypeReference<List<Long>>() {});
+        assertEquals(Arrays.asList(Long.MIN_VALUE, Long.MAX_VALUE), ll);
+        List<Long> ll2 = converter.convert(Arrays.asList(123, 345)).to(new TypeReference<List<Long>>()
{});
+        assertEquals(Arrays.asList(123L, 345L), ll2);
+
+    }
+
+    @Test
     public void testStandardStringArrayConversion() {
         String[] sa = {"A", "B"};
         assertEquals("A", converter.convert(sa).toString());



Mime
View raw message