You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by Radovan Semancik <ra...@evolveum.com> on 2018/07/11 15:40:09 UTC
Flexible schema error handling
Hi,
I have pushed my changes. It is pretty simple from the user point of view:
defaultSchemaManager.setErrorHandler(schemaErrorHandler);
I have removed old List<Throwable> errors and replaced it with
SchemaErrorHandler interface. I have figured that it is actually OK to
pay a cost of indirection here. It will only impact the servers with bad
schema, and those servers deserve to suffer anyway, right? :-) The real
reason was that by always using SchemaErrorHandler (and providing
default logging implemenation) I was able to somehow simplify and unify
error handling.
However, I have encountered two issues:
1) There are two dissociateFromSchema() methods in Registries. One of
them is used, the other seems not to be used at all. The difference was
in the parameters. When I removed the "errors" parameter then those
method clashed. They seem to do quite different things, so they probably
should not have the same name anyway (if both are really used). So I
have renamed the wrong one to dissociateFromSchemaQuestionable().
Emmanual, this is probably something you should have a look at. I feel a
bit lost here.
2) Ava. I think Ava is supposed to be a simple object, almost like a
DTO. It is a bit tangled with SchemaManager ... but I haven't found any
good way how to implement flexible logging in Ava (I do not want to
pollute SchemaManager interface with SchemaErrorHandler). But I have
realized that Ava is such a simple object, it probably should not log
the errors at all. It is throwing exceptions anyway. So I think it would
be responsibility of the caller to log errors (exceptions). So I have
removed the logging statements from Ava constructors. I hope that this
is OK. I have also found potential issues with Ava
comparison/normalization .... I have put a comment in the source code.
This is probably something to have a look in the future.
Overall, the solution is not perfect. But I'm quite happy with that for
2.0. It is definitely better than the temporary hack that we had in 1.0.
--
Radovan Semancik
Software Architect
evolveum.com
Re: Flexible schema error handling
Posted by Emmanuel Lécharny <el...@gmail.com>.
Le 12/07/2018 à 10:47, Radovan Semancik a écrit :
> On 07/12/2018 01:25 AM, Emmanuel Lécharny wrote:
>> It's almost a 10 years old code (OMG, I can't believe I wrote that
>> already 9 years ago...), and my guess is that when I added the list of
>> throwable, I forgot to remove the other method, which hasn't eveolved
>> since then, which explain why the code is so different.
>>
>> I thi,k we are safe if you simply remove the method you have renamed...
>
> Done. Gone. :-)
>
>>
>>> 2) Ava. I think Ava is supposed to be a simple object, almost like a
>>> DTO.
>> Not sure what you mean by DTO in this context... Because it's
>> serializable ?
>
> Ava is supposed to be (almost) simple data class without (much)
> dependencies on anything else in the API. At least that's how I
> understand it.
DTO carries some semantic that doe snot necessary apples to Ava (ie, a
DTO is supposed to be a Java object that contain data that can be sent
over the network (Data Transfert Object). In a way, it's correct, as a
DN is serialized to be sent to and from a LDAP server. That why I asked.
But Pojo/DTO/VO are names used in a J2EE context. I'm not too much in
using such acronyms. At least, I never have them in mind when I code...
To me, Ava is just a Java class, and it does what it has to be done...
Regardless...
>> Good job. Have you tried to build the server with those changes ? If
>> not, I will do that tomorrow evening.
>
> No, I haven't tried the server nor studio.
I have and I fixed the one ApacheDS compilation error, and the server
compile and builds. Committing the change atm.
We are good to go for a API release !
--
Emmanuel Lecharny
Symas.com
directory.apache.org
Re: Flexible schema error handling
Posted by Radovan Semancik <ra...@evolveum.com>.
On 07/12/2018 01:25 AM, Emmanuel Lécharny wrote:
> It's almost a 10 years old code (OMG, I can't believe I wrote that
> already 9 years ago...), and my guess is that when I added the list of
> throwable, I forgot to remove the other method, which hasn't eveolved
> since then, which explain why the code is so different.
>
> I thi,k we are safe if you simply remove the method you have renamed...
Done. Gone. :-)
>
>> 2) Ava. I think Ava is supposed to be a simple object, almost like a
>> DTO.
> Not sure what you mean by DTO in this context... Because it's serializable ?
Ava is supposed to be (almost) simple data class without (much)
dependencies on anything else in the API. At least that's how I
understand it. But I also understand the need for this to be (somehow)
schema-aware and currently I do not see any easy solution how to
properly refactor Ava. Anyway, I'm quite OK with current solution. The
logging statements in constructors were polluting logfiles during AD
schema parsing. But as they are now removed I'm good.
> I have also found potential issues with Ava
>> comparison/normalization .... I have put a comment in the source code.
>> This is probably something to have a look in the future.
> Actually, it's the equals() method, and in the comparison done when we
> have a SchemaManager, we have to assume the value of both Ava has
> already been normalized. This try-catch is a bit superfluous, we most
> certainly can get rid of it...
No problem with the current implementation. The error handling just
looked strange and suspicious. I remember I had some issues at this very
point with semi-schema-aware LDAPs like AD. But I was able to work
around it. So we are good with current code.
> Good job. Have you tried to build the server with those changes ? If
> not, I will do that tomorrow evening.
No, I haven't tried the server nor studio.
> Thanks Radovan !
And thank you for help and patience with me.
--
Radovan Semancik
Software Architect
evolveum.com
Re: Flexible schema error handling
Posted by Emmanuel Lécharny <el...@gmail.com>.
Le 11/07/2018 à 17:40, Radovan Semancik a écrit :
> Hi,
>
> I have pushed my changes. It is pretty simple from the user point of view:
>
> defaultSchemaManager.setErrorHandler(schemaErrorHandler);
>
> I have removed old List<Throwable> errors and replaced it with
> SchemaErrorHandler interface. I have figured that it is actually OK to
> pay a cost of indirection here. It will only impact the servers with bad
> schema, and those servers deserve to suffer anyway, right? :-) The real
> reason was that by always using SchemaErrorHandler (and providing
> default logging implemenation) I was able to somehow simplify and unify
> error handling.
Good.
>
> However, I have encountered two issues:
>
> 1) There are two dissociateFromSchema() methods in Registries. One of
> them is used, the other seems not to be used at all. The difference was
> in the parameters. When I removed the "errors" parameter then those
> method clashed. They seem to do quite different things, so they probably
> should not have the same name anyway (if both are really used). So I
> have renamed the wrong one to dissociateFromSchemaQuestionable().
> Emmanual, this is probably something you should have a look at. I feel a
> bit lost here.
Whoaa... You are doing some archeology here :-)
It's almost a 10 years old code (OMG, I can't believe I wrote that
already 9 years ago...), and my guess is that when I added the list of
throwable, I forgot to remove the other method, which hasn't eveolved
since then, which explain why the code is so different.
I thi,k we are safe if you simply remove the method you have renamed...
>
> 2) Ava. I think Ava is supposed to be a simple object, almost like a
> DTO.
Not sure what you mean by DTO in this context... Because it's serializable ?
It is a bit tangled with SchemaManager ... but I haven't found any
> good way how to implement flexible logging in Ava (I do not want to
> pollute SchemaManager interface with SchemaErrorHandler).
Ava are used in many parts of the server, this makes it a bit complex.
Typically, we need to have a schema awat-re Ava in the server, while the
client might not have any schema.
I'm not sure we need flexible logging in Ava though: it's enough to
throw an exception with the error message, as we do.
But I have
> realized that Ava is such a simple object, it probably should not log
> the errors at all.
I don't disagree... It was helpfull when I wrote the class, because
there are so many corner cases to deal wth, and the logs helped me back
then. Now, it's a bit spurious.
It is throwing exceptions anyway. So I think it would
> be responsibility of the caller to log errors (exceptions). So I have
> removed the logging statements from Ava constructors. I hope that this
> is OK.
I do think it's OK.
I have also found potential issues with Ava
> comparison/normalization .... I have put a comment in the source code.
> This is probably something to have a look in the future.
Actually, it's the equals() method, and in the comparison done when we
have a SchemaManager, we have to assume the value of both Ava has
already been normalized. This try-catch is a bit superfluous, we most
certainly can get rid of it...
>
> Overall, the solution is not perfect. But I'm quite happy with that for
> 2.0. It is definitely better than the temporary hack that we had in 1.0.
Good job. Have you tried to build the server with those changes ? If
not, I will do that tomorrow evening.
Thanks Radovan !
--
Emmanuel Lecharny
Symas.com
directory.apache.org