You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by da...@apache.org on 2017/04/07 13:33:37 UTC
svn commit: r1790551 - in /felix/trunk/converter/converter/src:
main/java/org/apache/felix/converter/impl/AdapterImpl.java
test/java/org/apache/felix/converter/impl/ConverterTest.java
test/java/org/apache/felix/converter/impl/Helper.java
Author: davidb
Date: Fri Apr 7 13:33:37 2017
New Revision: 1790551
URL: http://svn.apache.org/viewvc?rev=1790551&view=rev
Log:
Fix compilation errors in converter now that handleError() has been removed.
Modified:
felix/trunk/converter/converter/src/main/java/org/apache/felix/converter/impl/AdapterImpl.java
felix/trunk/converter/converter/src/test/java/org/apache/felix/converter/impl/ConverterTest.java
felix/trunk/converter/converter/src/test/java/org/apache/felix/converter/impl/Helper.java
Modified: felix/trunk/converter/converter/src/main/java/org/apache/felix/converter/impl/AdapterImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/converter/src/main/java/org/apache/felix/converter/impl/AdapterImpl.java?rev=1790551&r1=1790550&r2=1790551&view=diff
==============================================================================
--- felix/trunk/converter/converter/src/main/java/org/apache/felix/converter/impl/AdapterImpl.java (original)
+++ felix/trunk/converter/converter/src/main/java/org/apache/felix/converter/impl/AdapterImpl.java Fri Apr 7 13:33:37 2017
@@ -167,11 +167,11 @@ public class AdapterImpl implements Inte
return del.to(type);
} catch (Exception ex) {
// TODO do custom error handling
- for (ConvertFunction<?> cf : converters) {
- Object eh = cf.handleError(object, type);
- if (eh != null)
- return eh;
- }
+// for (ConvertFunction<?> cf : converters) {
+// Object eh = cf.handleError(object, type);
+// if (eh != null)
+// return eh;
+// }
// No error handler, throw the original exception
throw ex;
Modified: felix/trunk/converter/converter/src/test/java/org/apache/felix/converter/impl/ConverterTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/converter/src/test/java/org/apache/felix/converter/impl/ConverterTest.java?rev=1790551&r1=1790550&r2=1790551&view=diff
==============================================================================
--- felix/trunk/converter/converter/src/test/java/org/apache/felix/converter/impl/ConverterTest.java (original)
+++ felix/trunk/converter/converter/src/test/java/org/apache/felix/converter/impl/ConverterTest.java Fri Apr 7 13:33:37 2017
@@ -56,7 +56,6 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.osgi.util.converter.ConversionException;
-import org.osgi.util.converter.ConvertFunction;
import org.osgi.util.converter.Converter;
import org.osgi.util.converter.ConverterBuilder;
import org.osgi.util.converter.Rule;
@@ -346,37 +345,37 @@ public class ConverterTest {
assertArrayEquals(ia, adapted.convert("1,2").to(int[].class));
}
- @Test
- public void testCustomErrorHandling() {
- ConvertFunction<Integer> func = new ConvertFunction<Integer>() {
- @Override
- public Integer convert(Object obj, Type targetType) throws Exception {
- return null;
- }
-
- @Override
- public Integer handleError(Object obj, Type targetType) {
- if ("hello".equals(obj)) {
- return -1;
- }
- return null;
- }
- };
-
- ConverterBuilder cb = converter.newConverterBuilder();
- Converter adapted = cb.rule(Integer.class, func).build();
-
- assertEquals(new Integer(12), adapted.convert("12").to(Integer.class));
- assertEquals(new Integer(-1), adapted.convert("hello").to(Integer.class));
-
- // This is with the non-adapted converter
- try {
- converter.convert("hello").to(Integer.class);
- fail("Should have thrown a Conversion Exception when converting 'hello' to a number");
- } catch (ConversionException ce) {
- // good
- }
- }
+// @Test
+// public void testCustomErrorHandling() {
+// ConvertFunction<Integer> func = new ConvertFunction<Integer>() {
+// @Override
+// public Integer convert(Object obj, Type targetType) throws Exception {
+// return null;
+// }
+//
+// @Override
+// public Integer handleError(Object obj, Type targetType) {
+// if ("hello".equals(obj)) {
+// return -1;
+// }
+// return null;
+// }
+// };
+//
+// ConverterBuilder cb = converter.newConverterBuilder();
+// Converter adapted = cb.rule(Integer.class, func).build();
+//
+// assertEquals(new Integer(12), adapted.convert("12").to(Integer.class));
+// assertEquals(new Integer(-1), adapted.convert("hello").to(Integer.class));
+//
+// // This is with the non-adapted converter
+// try {
+// converter.convert("hello").to(Integer.class);
+// fail("Should have thrown a Conversion Exception when converting 'hello' to a number");
+// } catch (ConversionException ce) {
+// // good
+// }
+// }
@Test
public void testUUIDConversion() {
Modified: felix/trunk/converter/converter/src/test/java/org/apache/felix/converter/impl/Helper.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/converter/src/test/java/org/apache/felix/converter/impl/Helper.java?rev=1790551&r1=1790550&r2=1790551&view=diff
==============================================================================
--- felix/trunk/converter/converter/src/test/java/org/apache/felix/converter/impl/Helper.java (original)
+++ felix/trunk/converter/converter/src/test/java/org/apache/felix/converter/impl/Helper.java Fri Apr 7 13:33:37 2017
@@ -16,10 +16,10 @@
*/
package org.apache.felix.converter.impl;
-import org.osgi.util.converter.ConvertFunction;
-
import java.lang.reflect.Type;
+import org.osgi.util.converter.ConvertFunction;
+
public class Helper {
@FunctionalInterface
@@ -42,11 +42,6 @@ public class Helper {
public T convert(Object obj, Type targetType) throws Exception {
return converter != null ? converter.convert(obj, targetType) : null;
}
-
- @Override
- public T handleError(Object obj, Type targetType) {
- return errorHandler != null ? errorHandler.handleError(obj, targetType) : null;
- }
};
}