You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@syncope.apache.org by Francesco Chicchiriccò <il...@apache.org> on 2013/02/01 14:12:15 UTC
IncompatiblePolicyException was made unchecked
Hi all,
I've just noticed that IncompatiblePolicyException, created checked [1]
is now unchecked: any reason for this?
[1]
http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/util/IncompatiblePolicyException.java?view=markup&pathrev=1401200
--
Francesco Chicchiriccò
ASF Member, Apache Syncope PMC chair, Apache Cocoon PMC Member
http://people.apache.org/~ilgrosso/
Re: IncompatiblePolicyException was made unchecked
Posted by Francesco Chicchiriccò <il...@apache.org>.
On 01/02/2013 15:12, Andrei Shakirin wrote:
> Hi Francesco,
>
>> You're right about [1] and [2] - only, I have just realized now, working on
>> SYNCOPE-136, that ignoring this exception can be very dangerous during the
>> propagation process. And having it checked helps definitely in this sense.
>> Let's put it the other way round: why have it unchecked?
> Accordingly Java Best Practices checked exceptions should be used only for conditions from which the caller can reasonably be expected to recover.
> Runtime exceptions should be used for preconditions violation and for programming errors.
> If user have real possibility to improve the situation, exception should be checked.
> Not sure about IncompatiblePolicyException: is it related to passwords format only? In this case I tend to change exception back to checked, because user can react on exception and try again with improved password.
IncompatiblePolicyException is thrown by PasswordGenerator when the set
of password policies that are taken into account during random password
generation led to some incompatible constraints: for example policy A
says "length > 10 chars" and policy B says "length <= 8 chars".
In our case, the caller can somehow try to recover from this kind of
exception: take a look at ConnObjectUtil.getAttributableTO()
try {
password = pwdGen.generatePasswordFromPwdSpec(ppSpecs);
} catch (IncompatiblePolicyException e) {
LOG.error("Could not generate policy-compliant random
password for {}", subjectTO, e);
password = RandomStringUtils.randomAlphanumeric(16);
}
Regards.
>> -----Original Message-----
>> From: Francesco Chicchiriccò [mailto:ilgrosso@apache.org]
>> Sent: Freitag, 1. Februar 2013 14:37
>> To: dev@syncope.apache.org
>> Subject: Re: IncompatiblePolicyException was made unchecked
>>
>> On 01/02/2013 14:33, Andrei Shakirin wrote:
>>> Hi Francesco,
>>>
>>> I thought it was agreed in [1]. Have seen no objections in [2].
>> You're right about [1] and [2] - only, I have just realized now, working on
>> SYNCOPE-136, that ignoring this exception can be very dangerous during the
>> propagation process. And having it checked helps definitely in this sense.
>>
>>> Do you have reasons to keep this exception checked?
>> Let's put it the other way round: why have it unchecked?
>>
>> Regards.
>>
>>> [1]
>>>
>> https://cwiki.apache.org/confluence/display/SYNCOPE/Remote+Exceptions
>>> [2]
>>> http://syncope-dev.1063484.n5.nabble.com/Exception-propagation-in-
>> Rest
>>> -interface-HTTP-header-vs-body-for-details-td5711482.html
>>>
>>>> -----Original Message-----
>>>> From: Francesco Chicchiriccò [mailto:ilgrosso@apache.org]
>>>> Sent: Freitag, 1. Februar 2013 14:12
>>>> To: dev@syncope.apache.org
>>>> Subject: IncompatiblePolicyException was made unchecked
>>>>
>>>> Hi all,
>>>> I've just noticed that IncompatiblePolicyException, created checked
>>>> [1] is now unchecked: any reason for this?
>>>>
>>>> [1]
>>>>
>> http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/main/ja
>>>> va
>>>>
>> /org/apache/syncope/core/util/IncompatiblePolicyException.java?view=m
>>>> ar
>>>> kup&pathrev=1401200
>> --
>> Francesco Chicchiriccò
>>
>> ASF Member, Apache Syncope PMC chair, Apache Cocoon PMC Member
>> http://people.apache.org/~ilgrosso/
--
Francesco Chicchiriccò
ASF Member, Apache Syncope PMC chair, Apache Cocoon PMC Member
http://people.apache.org/~ilgrosso/
RE: IncompatiblePolicyException was made unchecked
Posted by Andrei Shakirin <as...@talend.com>.
Hi Francesco,
> You're right about [1] and [2] - only, I have just realized now, working on
> SYNCOPE-136, that ignoring this exception can be very dangerous during the
> propagation process. And having it checked helps definitely in this sense.
> Let's put it the other way round: why have it unchecked?
Accordingly Java Best Practices checked exceptions should be used only for conditions from which the caller can reasonably be expected to recover.
Runtime exceptions should be used for preconditions violation and for programming errors.
If user have real possibility to improve the situation, exception should be checked.
Not sure about IncompatiblePolicyException: is it related to passwords format only? In this case I tend to change exception back to checked, because user can react on exception and try again with improved password.
Cheers,
Andrei.
> -----Original Message-----
> From: Francesco Chicchiriccò [mailto:ilgrosso@apache.org]
> Sent: Freitag, 1. Februar 2013 14:37
> To: dev@syncope.apache.org
> Subject: Re: IncompatiblePolicyException was made unchecked
>
> On 01/02/2013 14:33, Andrei Shakirin wrote:
> > Hi Francesco,
> >
> > I thought it was agreed in [1]. Have seen no objections in [2].
>
> You're right about [1] and [2] - only, I have just realized now, working on
> SYNCOPE-136, that ignoring this exception can be very dangerous during the
> propagation process. And having it checked helps definitely in this sense.
>
> > Do you have reasons to keep this exception checked?
>
> Let's put it the other way round: why have it unchecked?
>
> Regards.
>
> > [1]
> >
> https://cwiki.apache.org/confluence/display/SYNCOPE/Remote+Exceptions
> > [2]
> > http://syncope-dev.1063484.n5.nabble.com/Exception-propagation-in-
> Rest
> > -interface-HTTP-header-vs-body-for-details-td5711482.html
> >
> >> -----Original Message-----
> >> From: Francesco Chicchiriccò [mailto:ilgrosso@apache.org]
> >> Sent: Freitag, 1. Februar 2013 14:12
> >> To: dev@syncope.apache.org
> >> Subject: IncompatiblePolicyException was made unchecked
> >>
> >> Hi all,
> >> I've just noticed that IncompatiblePolicyException, created checked
> >> [1] is now unchecked: any reason for this?
> >>
> >> [1]
> >>
> http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/main/ja
> >> va
> >>
> /org/apache/syncope/core/util/IncompatiblePolicyException.java?view=m
> >> ar
> >> kup&pathrev=1401200
>
> --
> Francesco Chicchiriccò
>
> ASF Member, Apache Syncope PMC chair, Apache Cocoon PMC Member
> http://people.apache.org/~ilgrosso/
Re: IncompatiblePolicyException was made unchecked
Posted by Christian Schneider <ch...@die-schneider.net>.
Basically I prefer unchecked but this would rather be a general change
to not use checked exceptions at all.
I do not insist on this style though and will go with the majority.
Christian
Am 02.02.2013 11:26, schrieb Francesco Chicchiriccò:
> On 01/02/2013 17:44, Andrei Shakirin wrote:
>> Can we agree on something here?
>>
>> My +1 for checked
>
> +1 from me as well.
>
> Regards.
>
--
Christian Schneider
http://www.liquid-reality.de
Open Source Architect
Talend Application Integration Division http://www.talend.com
Re: IncompatiblePolicyException was made unchecked
Posted by Francesco Chicchiriccò <il...@apache.org>.
On 01/02/2013 17:44, Andrei Shakirin wrote:
> Can we agree on something here?
>
> My +1 for checked
+1 from me as well.
Regards.
--
Francesco Chicchiriccò
ASF Member, Apache Syncope PMC chair, Apache Cocoon PMC Member
http://people.apache.org/~ilgrosso/
RE: IncompatiblePolicyException was made unchecked
Posted by Andrei Shakirin <as...@talend.com>.
Can we agree on something here?
My +1 for checked
> -----Original Message-----
> From: Christian Schneider [mailto:cschneider111@gmail.com] On Behalf Of
> Christian Schneider
> Sent: Freitag, 1. Februar 2013 15:14
> To: dev@syncope.apache.org
> Subject: Re: IncompatiblePolicyException was made unchecked
>
> Sorry about the long explanation that is completely unrelated to this special
> case but I think the discussion checked vs unchecked exceptions is a general
> thing so I write a general reasoning...
>
> In general checked Exceptions force the user of an API to handle an
> exception at exactly the point where it happens.
> Often thoughit is much easier to let an exception bubble up the stack to a
> general place where exceptions are handled. Checked exceptions also force
> to Map an exception at every layer of an application. The reason is that
> simply throwing exceptions over layer boundaries violates encapsulation.
>
> So my way of handling checked exceptions is: where they are forced upon
> me by an API I map them to an unchecked Exception as soon as possible to
> limit their effect / damage.
>
> I have found a nice explanation on this article
> http://www.javacodegeeks.com/2012/03/why-should-you-use-unchecked-
> exceptions.html
> > In his famous book, *Clean code: a handbook of agile software
> > craftsmanship*[3
> >
> <http://books.google.co.in/books/about/Clean_code.html?id=dwSfGQAAC
> AAJ
> > &redir_esc=y>], Robert C. Martin writes the below lines supporting
> > Unchecked Exceptions.
> >
> > /The debate is over. For years Java programmers have debated over the
> > benefits and liabilities //of checked exceptions. When checked
> > exceptions were introduced in the first version //of Java, they seemed
> > like a great idea. The signature of every method would list all of the
> > //exceptions that it could pass to its caller. Moreover, these
> > exceptions were part of the type/ /of the method. Your code literally
> > wouldn't compile if the signature didn't match what your //code could
> > do./ / / /At the time, we thought that checked exceptions were a great
> > idea; and yes, they can //yield some benefit. However, it is clear now
> > that they aren't necessary for the production of //robust software. C#
> > doesn't have checked exceptions, and despite valiant attempts, C++
> > //doesn't either. Neither do Python or Ruby. Yet it is possible to
> > write robust software in all //of these languages. Because that is the
> > case, we have to decide---really---whether checked //exceptions are
> > worth their price./ / /
>
> Here some more similar articles:
> http://tapestryjava.blogspot.in/2011/05/tragedy-of-checked-
> exceptions.html
> http://blogs.atlassian.com/2011/05/exceptions_are_bad/
> http://misko.hevery.com/2009/09/16/checked-exceptions-i-love-you-but-
> you-have-to-go/
>
> Christian
>
> Am 01.02.2013 14:36, schrieb Francesco Chicchiriccò:
> > On 01/02/2013 14:33, Andrei Shakirin wrote:
> >> Hi Francesco,
> >>
> >> I thought it was agreed in [1]. Have seen no objections in [2].
> >
> > You're right about [1] and [2] - only, I have just realized now,
> > working on SYNCOPE-136, that ignoring this exception can be very
> > dangerous during the propagation process. And having it checked helps
> > definitely in this sense.
> >
> >> Do you have reasons to keep this exception checked?
> >
> > Let's put it the other way round: why have it unchecked?
> >
> > Regards.
> >
> >> [1]
> >>
> https://cwiki.apache.org/confluence/display/SYNCOPE/Remote+Exceptions
> >> [2]
> >> http://syncope-dev.1063484.n5.nabble.com/Exception-propagation-in-
> Res
> >> t-interface-HTTP-header-vs-body-for-details-td5711482.html
> >>
> >>> -----Original Message-----
> >>> From: Francesco Chicchiriccò [mailto:ilgrosso@apache.org]
> >>> Sent: Freitag, 1. Februar 2013 14:12
> >>> To: dev@syncope.apache.org
> >>> Subject: IncompatiblePolicyException was made unchecked
> >>>
> >>> Hi all,
> >>> I've just noticed that IncompatiblePolicyException, created checked
> >>> [1] is now unchecked: any reason for this?
> >>>
> >>> [1]
> >>>
> http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/main/j
> >>> ava
> >>>
> /org/apache/syncope/core/util/IncompatiblePolicyException.java?view=
> >>> mar
> >>> kup&pathrev=1401200
> >
>
>
> --
>
> Christian Schneider
> http://www.liquid-reality.de
>
> Open Source Architect
> Talend Application Integration Division http://www.talend.com
Re: IncompatiblePolicyException was made unchecked
Posted by Christian Schneider <ch...@die-schneider.net>.
Sorry about the long explanation that is completely unrelated to this
special case but I think the discussion checked vs unchecked exceptions
is a general thing so I write a general reasoning...
In general checked Exceptions force the user of an API to handle an
exception at exactly the point where it happens.
Often thoughit is much easier to let an exception bubble up the stack to
a general place where exceptions are handled. Checked exceptions also
force to Map an exception at every layer of an application. The reason
is that simply throwing exceptions over layer boundaries violates
encapsulation.
So my way of handling checked exceptions is: where they are forced upon
me by an API I map them to an unchecked Exception as soon as possible to
limit their effect / damage.
I have found a nice explanation on this article
http://www.javacodegeeks.com/2012/03/why-should-you-use-unchecked-exceptions.html
> In his famous book, *Clean code: a handbook of agile software
> craftsmanship*[3
> <http://books.google.co.in/books/about/Clean_code.html?id=dwSfGQAACAAJ&redir_esc=y>],
> Robert C. Martin writes the below lines supporting Unchecked Exceptions.
>
> /The debate is over. For years Java programmers have debated over the
> benefits and liabilities //of checked exceptions. When checked
> exceptions were introduced in the first version //of Java, they seemed
> like a great idea. The signature of every method would list all of the
> //exceptions that it could pass to its caller. Moreover, these
> exceptions were part of the type/
> /of the method. Your code literally wouldn't compile if the signature
> didn't match what your //code could do./
> /
> /
> /At the time, we thought that checked exceptions were a great idea;
> and yes, they can //yield some benefit. However, it is clear now that
> they aren't necessary for the production of //robust software. C#
> doesn't have checked exceptions, and despite valiant attempts, C++
> //doesn't either. Neither do Python or Ruby. Yet it is possible to
> write robust software in all //of these languages. Because that is the
> case, we have to decide---really---whether checked //exceptions are
> worth their price./
> /
> /
Here some more similar articles:
http://tapestryjava.blogspot.in/2011/05/tragedy-of-checked-exceptions.html
http://blogs.atlassian.com/2011/05/exceptions_are_bad/
http://misko.hevery.com/2009/09/16/checked-exceptions-i-love-you-but-you-have-to-go/
Christian
Am 01.02.2013 14:36, schrieb Francesco Chicchiriccò:
> On 01/02/2013 14:33, Andrei Shakirin wrote:
>> Hi Francesco,
>>
>> I thought it was agreed in [1]. Have seen no objections in [2].
>
> You're right about [1] and [2] - only, I have just realized now,
> working on SYNCOPE-136, that ignoring this exception can be very
> dangerous during the propagation process. And having it checked helps
> definitely in this sense.
>
>> Do you have reasons to keep this exception checked?
>
> Let's put it the other way round: why have it unchecked?
>
> Regards.
>
>> [1]
>> https://cwiki.apache.org/confluence/display/SYNCOPE/Remote+Exceptions
>> [2]
>> http://syncope-dev.1063484.n5.nabble.com/Exception-propagation-in-Rest-interface-HTTP-header-vs-body-for-details-td5711482.html
>>
>>> -----Original Message-----
>>> From: Francesco Chicchiriccò [mailto:ilgrosso@apache.org]
>>> Sent: Freitag, 1. Februar 2013 14:12
>>> To: dev@syncope.apache.org
>>> Subject: IncompatiblePolicyException was made unchecked
>>>
>>> Hi all,
>>> I've just noticed that IncompatiblePolicyException, created checked
>>> [1] is
>>> now unchecked: any reason for this?
>>>
>>> [1]
>>> http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/main/java
>>> /org/apache/syncope/core/util/IncompatiblePolicyException.java?view=mar
>>> kup&pathrev=1401200
>
--
Christian Schneider
http://www.liquid-reality.de
Open Source Architect
Talend Application Integration Division http://www.talend.com
Re: IncompatiblePolicyException was made unchecked
Posted by Francesco Chicchiriccò <il...@apache.org>.
On 01/02/2013 14:33, Andrei Shakirin wrote:
> Hi Francesco,
>
> I thought it was agreed in [1]. Have seen no objections in [2].
You're right about [1] and [2] - only, I have just realized now, working
on SYNCOPE-136, that ignoring this exception can be very dangerous
during the propagation process. And having it checked helps definitely
in this sense.
> Do you have reasons to keep this exception checked?
Let's put it the other way round: why have it unchecked?
Regards.
> [1] https://cwiki.apache.org/confluence/display/SYNCOPE/Remote+Exceptions
> [2] http://syncope-dev.1063484.n5.nabble.com/Exception-propagation-in-Rest-interface-HTTP-header-vs-body-for-details-td5711482.html
>
>> -----Original Message-----
>> From: Francesco Chicchiriccò [mailto:ilgrosso@apache.org]
>> Sent: Freitag, 1. Februar 2013 14:12
>> To: dev@syncope.apache.org
>> Subject: IncompatiblePolicyException was made unchecked
>>
>> Hi all,
>> I've just noticed that IncompatiblePolicyException, created checked [1] is
>> now unchecked: any reason for this?
>>
>> [1]
>> http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/main/java
>> /org/apache/syncope/core/util/IncompatiblePolicyException.java?view=mar
>> kup&pathrev=1401200
--
Francesco Chicchiriccò
ASF Member, Apache Syncope PMC chair, Apache Cocoon PMC Member
http://people.apache.org/~ilgrosso/
RE: IncompatiblePolicyException was made unchecked
Posted by Andrei Shakirin <as...@talend.com>.
Hi Francesco,
I thought it was agreed in [1]. Have seen no objections in [2].
Do you have reasons to keep this exception checked?
Regards,
Andrei.
[1] https://cwiki.apache.org/confluence/display/SYNCOPE/Remote+Exceptions
[2] http://syncope-dev.1063484.n5.nabble.com/Exception-propagation-in-Rest-interface-HTTP-header-vs-body-for-details-td5711482.html
> -----Original Message-----
> From: Francesco Chicchiriccò [mailto:ilgrosso@apache.org]
> Sent: Freitag, 1. Februar 2013 14:12
> To: dev@syncope.apache.org
> Subject: IncompatiblePolicyException was made unchecked
>
> Hi all,
> I've just noticed that IncompatiblePolicyException, created checked [1] is
> now unchecked: any reason for this?
>
> [1]
> http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/main/java
> /org/apache/syncope/core/util/IncompatiblePolicyException.java?view=mar
> kup&pathrev=1401200
>
> --
> Francesco Chicchiriccò
>
> ASF Member, Apache Syncope PMC chair, Apache Cocoon PMC Member
> http://people.apache.org/~ilgrosso/