You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Harrison Tarr <ha...@connexta.com> on 2018/05/10 01:27:07 UTC

Weird backslash/escape behavior in Felix using Karaf

Hi all,

I'm trying to resolve a bug with a configuration. The issue is with the handling of backslashes. My config is a Windows path, eg: 'fileRoot="\\127.0.0.1\file\path\"'. I did some experimenting in the Felix code and I seemed to have found a work around that didn't break any unit tests; I realized after, once building the whole module, that it did in fact break unit tests of a different class. I noticed that the behavior that did not agree with what I expected was in the `readQuoted` method of the `ConfigurationHandler` class. (Pull request and bug JIRA for reference: https://github.com/apache/felix/pull/136 https://issues.apache.org/jira/browse/FELIX-5849)

Anyway, I loaded my customized module into my project and promptly noticed that I was still having the issue - in fact, my new code wasn't even being hit. It appears that Karaf doesn't use the `read` methods in the `ConfigurationHandler` class, but does use the `write` methods. Does anyone know where else the config could be getting read from?

Best Regards,

Harrison Tarr

Re: Weird backslash/escape behavior in Felix using Karaf

Posted by Guillaume Nodet <gn...@apache.org>.
Could you try the same kind of tests using the TypedProperties from felix
utils ?  It does have an interpolation layer which could be the culprit by
escaping twice at the end...

2018-05-10 22:10 GMT+02:00 Harrison Tarr <ha...@connexta.com>:

> Carsten Ziegeler commented on my ticket in JIRA and mentioned that he
> doesn't think it's a bug with the ConfigurationHandler. I have added an
> additional test to the ConfigurationHandler where I write a config, read it
> and write it again and have confirmed that it stays consistent. (I have
> updated my PR with the new code) I wonder where this inconsistency is
> happening? It's almost like it reads it twice before writing it. For
> example, the written config should have `\\\\` and then it is read in and
> it gets turned into `\\` but then it is again written out as `\\`. This
> makes me think it is reading `\\\\` turning it into `\\` (which makes
> sense) but then somewhere it is reading it again and turning it into `\`
> which then gets written out as `\\` and then eventually turned into
> nothing.  Any ideas where that could be happening?
>
> Harrison
>
> -----Original Message-----
> From: Harrison Tarr <ha...@connexta.com>
> Sent: Thursday, May 10, 2018 11:53 AM
> To: users@felix.apache.org
> Subject: RE: Weird backslash/escape behavior in Felix using Karaf
>
> Hi Guillaume,
>
> I think that's exactly the case. I put some breakpoints in that copy of
> the ConfigurationHandler and the read method was hit. It still looks like
> it doesn't necessarily handle the backslashes the way I would expect. Does
> anyone have any insight into that?
>
> Harrison
>
> -----Original Message-----
> From: Guillaume Nodet <gn...@apache.org>
> Sent: Wednesday, May 9, 2018 6:57 PM
> To: users@felix.apache.org
> Subject: Re: Weird backslash/escape behavior in Felix using Karaf
>
> FileInstall now uses the TypedProperties class to read the configuration.
> It has its own copy of the ConfigurationHandler class:
>
> https://github.com/apache/felix/tree/trunk/utils/src/
> main/java/org/apache/felix/utils/properties
>
> Maybe that's the reason why you didn't hit your code ?
>
> Guillaume
>
> 2018-05-10 3:27 GMT+02:00 Harrison Tarr <ha...@connexta.com>:
>
> > Hi all,
> >
> > I'm trying to resolve a bug with a configuration. The issue is with
> > the handling of backslashes. My config is a Windows path, eg:
> > 'fileRoot="\\127.0.0.1\file\path\"'. I did some experimenting in the
> > Felix code and I seemed to have found a work around that didn't break
> > any unit tests; I realized after, once building the whole module, that
> > it did in fact break unit tests of a different class. I noticed that
> > the behavior that did not agree with what I expected was in the
> > `readQuoted` method of the `ConfigurationHandler` class. (Pull request
> and bug JIRA for reference:
> > https://github.com/apache/felix/pull/136 https://issues.apache.org/
> > jira/browse/FELIX-5849)
> >
> > Anyway, I loaded my customized module into my project and promptly
> > noticed that I was still having the issue - in fact, my new code
> > wasn't even being hit. It appears that Karaf doesn't use the `read`
> > methods in the `ConfigurationHandler` class, but does use the `write`
> > methods. Does anyone know where else the config could be getting read
> from?
> >
> > Best Regards,
> >
> > Harrison Tarr
> >
>
>
>
> --
> ------------------------
> Guillaume Nodet
>



-- 
------------------------
Guillaume Nodet

RE: Weird backslash/escape behavior in Felix using Karaf

Posted by Harrison Tarr <ha...@connexta.com>.
Carsten Ziegeler commented on my ticket in JIRA and mentioned that he doesn't think it's a bug with the ConfigurationHandler. I have added an additional test to the ConfigurationHandler where I write a config, read it and write it again and have confirmed that it stays consistent. (I have updated my PR with the new code) I wonder where this inconsistency is happening? It's almost like it reads it twice before writing it. For example, the written config should have `\\\\` and then it is read in and it gets turned into `\\` but then it is again written out as `\\`. This makes me think it is reading `\\\\` turning it into `\\` (which makes sense) but then somewhere it is reading it again and turning it into `\` which then gets written out as `\\` and then eventually turned into nothing.  Any ideas where that could be happening? 

Harrison 

-----Original Message-----
From: Harrison Tarr <ha...@connexta.com> 
Sent: Thursday, May 10, 2018 11:53 AM
To: users@felix.apache.org
Subject: RE: Weird backslash/escape behavior in Felix using Karaf

Hi Guillaume,

I think that's exactly the case. I put some breakpoints in that copy of the ConfigurationHandler and the read method was hit. It still looks like it doesn't necessarily handle the backslashes the way I would expect. Does anyone have any insight into that?

Harrison

-----Original Message-----
From: Guillaume Nodet <gn...@apache.org>
Sent: Wednesday, May 9, 2018 6:57 PM
To: users@felix.apache.org
Subject: Re: Weird backslash/escape behavior in Felix using Karaf

FileInstall now uses the TypedProperties class to read the configuration.
It has its own copy of the ConfigurationHandler class:

https://github.com/apache/felix/tree/trunk/utils/src/main/java/org/apache/felix/utils/properties

Maybe that's the reason why you didn't hit your code ?

Guillaume

2018-05-10 3:27 GMT+02:00 Harrison Tarr <ha...@connexta.com>:

> Hi all,
>
> I'm trying to resolve a bug with a configuration. The issue is with 
> the handling of backslashes. My config is a Windows path, eg:
> 'fileRoot="\\127.0.0.1\file\path\"'. I did some experimenting in the 
> Felix code and I seemed to have found a work around that didn't break 
> any unit tests; I realized after, once building the whole module, that 
> it did in fact break unit tests of a different class. I noticed that 
> the behavior that did not agree with what I expected was in the 
> `readQuoted` method of the `ConfigurationHandler` class. (Pull request and bug JIRA for reference:
> https://github.com/apache/felix/pull/136 https://issues.apache.org/
> jira/browse/FELIX-5849)
>
> Anyway, I loaded my customized module into my project and promptly 
> noticed that I was still having the issue - in fact, my new code 
> wasn't even being hit. It appears that Karaf doesn't use the `read` 
> methods in the `ConfigurationHandler` class, but does use the `write` 
> methods. Does anyone know where else the config could be getting read from?
>
> Best Regards,
>
> Harrison Tarr
>



--
------------------------
Guillaume Nodet

RE: Weird backslash/escape behavior in Felix using Karaf

Posted by Harrison Tarr <ha...@connexta.com>.
Hi Guillaume,

I think that's exactly the case. I put some breakpoints in that copy of the ConfigurationHandler and the read method was hit. It still looks like it doesn't necessarily handle the backslashes the way I would expect. Does anyone have any insight into that?

Harrison

-----Original Message-----
From: Guillaume Nodet <gn...@apache.org> 
Sent: Wednesday, May 9, 2018 6:57 PM
To: users@felix.apache.org
Subject: Re: Weird backslash/escape behavior in Felix using Karaf

FileInstall now uses the TypedProperties class to read the configuration.
It has its own copy of the ConfigurationHandler class:

https://github.com/apache/felix/tree/trunk/utils/src/main/java/org/apache/felix/utils/properties

Maybe that's the reason why you didn't hit your code ?

Guillaume

2018-05-10 3:27 GMT+02:00 Harrison Tarr <ha...@connexta.com>:

> Hi all,
>
> I'm trying to resolve a bug with a configuration. The issue is with 
> the handling of backslashes. My config is a Windows path, eg:
> 'fileRoot="\\127.0.0.1\file\path\"'. I did some experimenting in the 
> Felix code and I seemed to have found a work around that didn't break 
> any unit tests; I realized after, once building the whole module, that 
> it did in fact break unit tests of a different class. I noticed that 
> the behavior that did not agree with what I expected was in the 
> `readQuoted` method of the `ConfigurationHandler` class. (Pull request and bug JIRA for reference:
> https://github.com/apache/felix/pull/136 https://issues.apache.org/
> jira/browse/FELIX-5849)
>
> Anyway, I loaded my customized module into my project and promptly 
> noticed that I was still having the issue - in fact, my new code 
> wasn't even being hit. It appears that Karaf doesn't use the `read` 
> methods in the `ConfigurationHandler` class, but does use the `write` 
> methods. Does anyone know where else the config could be getting read from?
>
> Best Regards,
>
> Harrison Tarr
>



--
------------------------
Guillaume Nodet

Re: Weird backslash/escape behavior in Felix using Karaf

Posted by Guillaume Nodet <gn...@apache.org>.
FileInstall now uses the TypedProperties class to read the configuration.
It has its own copy of the ConfigurationHandler class:

https://github.com/apache/felix/tree/trunk/utils/src/main/java/org/apache/felix/utils/properties

Maybe that's the reason why you didn't hit your code ?

Guillaume

2018-05-10 3:27 GMT+02:00 Harrison Tarr <ha...@connexta.com>:

> Hi all,
>
> I'm trying to resolve a bug with a configuration. The issue is with the
> handling of backslashes. My config is a Windows path, eg:
> 'fileRoot="\\127.0.0.1\file\path\"'. I did some experimenting in the
> Felix code and I seemed to have found a work around that didn't break any
> unit tests; I realized after, once building the whole module, that it did
> in fact break unit tests of a different class. I noticed that the behavior
> that did not agree with what I expected was in the `readQuoted` method of
> the `ConfigurationHandler` class. (Pull request and bug JIRA for reference:
> https://github.com/apache/felix/pull/136 https://issues.apache.org/
> jira/browse/FELIX-5849)
>
> Anyway, I loaded my customized module into my project and promptly noticed
> that I was still having the issue - in fact, my new code wasn't even being
> hit. It appears that Karaf doesn't use the `read` methods in the
> `ConfigurationHandler` class, but does use the `write` methods. Does anyone
> know where else the config could be getting read from?
>
> Best Regards,
>
> Harrison Tarr
>



-- 
------------------------
Guillaume Nodet