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

cziegeler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/felix-dev.git


The following commit(s) were added to refs/heads/master by this push:
     new 6cd9916c31 FELIX-6577 : Catch ConversionException from Converter
6cd9916c31 is described below

commit 6cd9916c3115b868bccfb886d5605e240d105792
Author: Carsten Ziegeler <[email protected]>
AuthorDate: Fri Nov 4 06:31:33 2022 +0100

    FELIX-6577 : Catch ConversionException from Converter
---
 .../org/apache/felix/cm/json/impl/ConfigurationReaderImpl.java    | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git 
a/cm.json/src/main/java/org/apache/felix/cm/json/impl/ConfigurationReaderImpl.java
 
b/cm.json/src/main/java/org/apache/felix/cm/json/impl/ConfigurationReaderImpl.java
index 91a084884a..159d86ed6f 100644
--- 
a/cm.json/src/main/java/org/apache/felix/cm/json/impl/ConfigurationReaderImpl.java
+++ 
b/cm.json/src/main/java/org/apache/felix/cm/json/impl/ConfigurationReaderImpl.java
@@ -34,6 +34,7 @@ import org.apache.felix.cm.json.ConfigurationReader;
 import org.apache.felix.cm.json.ConfigurationResource;
 import org.apache.felix.cm.json.Configurations;
 import org.osgi.service.configurator.ConfiguratorConstants;
+import org.osgi.util.converter.ConversionException;
 import org.osgi.util.converter.Converters;
 
 public class ConfigurationReaderImpl
@@ -171,7 +172,12 @@ public class ConfigurationReaderImpl
         final Object version = JsonSupport
                 
.convertToObject(this.jsonObject.get(ConfiguratorConstants.PROPERTY_RESOURCE_VERSION));
         if (version != null) {
-            final int v = 
Converters.standardConverter().convert(version).defaultValue(-1).to(Integer.class);
+            int v = -1;
+            try {
+                v = 
Converters.standardConverter().convert(version).defaultValue(-1).to(Integer.class);
+            } catch ( final ConversionException ce ) {
+                // ignore
+            }
             if (v == -1) {
                 throwIOException("Invalid resource version information : 
".concat(version.toString()));
             }

Reply via email to