You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Robert Munteanu (JIRA)" <ji...@apache.org> on 2016/07/28 14:18:20 UTC
[jira] [Commented] (SLING-5914) Provisioning model does not
correctly handle floating-point configuration values
[ https://issues.apache.org/jira/browse/SLING-5914?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15397578#comment-15397578 ]
Robert Munteanu commented on SLING-5914:
----------------------------------------
The following change demonstrates the issue
{noformat}diff --git a/tooling/support/provisioning-model/src/test/java/org/apache/sling/provisioning/model/io/IOTest.java b/tooling/support/provisioning-model/src/test/java/org/apache/sling/provisioning/model/io/IOTest.java
index 6a7395a..ec1c8ef 100644
--- a/tooling/support/provisioning-model/src/test/java/org/apache/sling/provisioning/model/io/IOTest.java
+++ b/tooling/support/provisioning-model/src/test/java/org/apache/sling/provisioning/model/io/IOTest.java
@@ -93,7 +93,7 @@ public class IOTest {
configs.add(c);
}
- assertEquals(4, configs.size());
+ assertEquals(5, configs.size());
final Configuration cfgA = configs.get(0);
assertEquals("org.apache.test.A", cfgA.getPid());
@@ -104,7 +104,7 @@ public class IOTest {
final Configuration cfgB = configs.get(1);
assertEquals("org.apache.test.B", cfgB.getPid());
assertNull(cfgB.getFactoryPid());
- assertEquals(2, cfgB.getProperties().size());
+ assertEquals(3, cfgB.getProperties().size());
assertEquals("B", cfgB.getProperties().get("name"));
assertArrayEquals(new String[] {"one", "two", "three"}, (String[])cfgB.getProperties().get("array"));
@@ -119,6 +119,15 @@ public class IOTest {
assertEquals("org.apache.test.D", cfgD.getPid());
assertEquals("Here is\na multiline\nstring", cfgD.getProperties().get("textA"));
assertEquals("Another one\nusing\nescaped newlines", cfgD.getProperties().get("textB"));
+
+ final Configuration cfgE = configs.get(4);
+ assertEquals("org.apache.test.E", cfgE.getPid());
+ assertNull(cfgE.getFactoryPid());
+ assertEquals(4, cfgE.getProperties().size());
+ assertEquals(5.5, cfgE.getProperties().get("doubleValue"));
+ assertEquals(1.0f, cfgE.getProperties().get("floatValue"));
+ assertArrayEquals(new Double[] { 0.0, 3.0 }, (Double[]) cfgE.getProperties().get("doubles"));
+ assertArrayEquals(new Float[] { -1.0f, 1.0f }, (Double[]) cfgE.getProperties().get("floats"));
}
@Test public void testAddition() throws Exception {
diff --git a/tooling/support/provisioning-model/src/test/resources/configadmin.txt b/tooling/support/provisioning-model/src/test/resources/configadmin.txt
index 9c9d6f6..d36a8e5 100644
--- a/tooling/support/provisioning-model/src/test/resources/configadmin.txt
+++ b/tooling/support/provisioning-model/src/test/resources/configadmin.txt
@@ -32,7 +32,7 @@ org.apache.test.B
"two",
"three"
]
- name="B"
+ name="B"
org.apache.test.C
array=I[
@@ -46,4 +46,14 @@ org.apache.test.D
textA="Here is
a multiline
string"
- textB="Another one\nusing\nescaped newlines"
\ No newline at end of file
+ textB="Another one\nusing\nescaped newlines"
+
+org.apache.test.E
+ doubleValue=D"5.5"
+ floatValue=F"1.0"
+ doubles=D["0.0", "3.0"]
+ floats=F[
+ "-1.0",
+ "1.0"
+ ]
+
\ No newline at end of file
{noformat}
with {{IOTest.testMultilineConfiguration}} failing early:
{noformat}java.lang.NumberFormatException: For input string: "5.5"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
at java.lang.Long.parseLong(Long.java:419)
at java.lang.Long.parseLong(Long.java:468)
at org.apache.felix.cm.file.ConfigurationHandler.readSimple(ConfigurationHandler.java:468)
at org.apache.felix.cm.file.ConfigurationHandler.readValue(ConfigurationHandler.java:350)
at org.apache.felix.cm.file.ConfigurationHandler.readInternal(ConfigurationHandler.java:304)
at org.apache.felix.cm.file.ConfigurationHandler.read(ConfigurationHandler.java:263)
at org.apache.sling.provisioning.model.ModelResolveUtility.getProcessedConfiguration(ModelResolveUtility.java:166)
at org.apache.sling.provisioning.model.EffectiveModelProcessor.processConfiguration(EffectiveModelProcessor.java:59)
at org.apache.sling.provisioning.model.ModelProcessor.process(ModelProcessor.java:71)
at org.apache.sling.provisioning.model.ModelUtility.getEffectiveModel(ModelUtility.java:155)
at org.apache.sling.provisioning.model.ModelUtility.getEffectiveModel(ModelUtility.java:142)
at org.apache.sling.provisioning.model.io.IOTest.testMultilineConfiguration(IOTest.java:89)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192){noformat}
> Provisioning model does not correctly handle floating-point configuration values
> --------------------------------------------------------------------------------
>
> Key: SLING-5914
> URL: https://issues.apache.org/jira/browse/SLING-5914
> Project: Sling
> Issue Type: Bug
> Reporter: Robert Munteanu
> Fix For: Sling Provisioning Model 1.4.6
>
>
> The provisioning model specifies that floating-point values are encoded in the following format:
> - {{D"1.0"}} for doubles
> - {{F"1.0"}} for floats
> However, the ConfigAdmin has a different idea about how these values should be stored:
> {code:java}
> case TOKEN_SIMPLE_FLOAT:
> case TOKEN_PRIMITIVE_FLOAT:
> int fBits = Integer.parseInt( readQuoted( pr ) );
> return new Float( Float.intBitsToFloat( fBits ) );
> case TOKEN_SIMPLE_DOUBLE:
> case TOKEN_PRIMITIVE_DOUBLE:
> long dBits = Long.parseLong( readQuoted( pr ) );
> return new Double( Double.longBitsToDouble( dBits ) );
> {code}
> I assume that this is done to preserve precision when reading/writing values.
> The provisioning model should be updated to mediate between the user-supplied values and the configuration admin format.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)