You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jclouds.apache.org by Andrea Turli <no...@github.com> on 2013/11/14 00:37:00 UTC

[jclouds] JCLOUDS-373: Fix SoftLayerOrderItemDuplicateException. (#204)

- SoftLayerOrderItemDuplicateException extends IllegalStateException for consistency and for Throwables2.propagateIfPossible
You can merge this Pull Request by running:

  git pull https://github.com/andreaturli/jclouds fix/softlayer-exception

Or you can view, comment on it, or merge it online at:

  https://github.com/jclouds/jclouds/pull/204

-- Commit Summary --

  * JCLOUDS-373: Fix SoftLayerOrderItemDuplicateException.

-- File Changes --

    M providers/softlayer/src/main/java/org/jclouds/softlayer/exceptions/SoftLayerOrderItemDuplicateException.java (2)

-- Patch Links --

https://github.com/jclouds/jclouds/pull/204.patch
https://github.com/jclouds/jclouds/pull/204.diff

Re: [jclouds] JCLOUDS-373: Fix SoftLayerOrderItemDuplicateException. (#204)

Posted by Andrea Turli <no...@github.com>.
Thanks @demobox and @nacx !

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/204#issuecomment-28478432

Re: [jclouds] JCLOUDS-373: Fix SoftLayerOrderItemDuplicateException. (#204)

Posted by Andrew Phillips <no...@github.com>.
> @@ -16,7 +16,7 @@
>   */
>  package org.jclouds.softlayer.exceptions;
>  
> -public class SoftLayerOrderItemDuplicateException extends RuntimeException {
> +public class SoftLayerOrderItemDuplicateException extends IllegalStateException {

> This is quite a relevant change, so I think it is a good discussion have in the mailing list.

Indeed. If this is broken now and we want to fix it (which I can imagine we want to!), how about `IllegalArgumentException`, `UnsupportedOperationException` (meh), `ResourceNotFoundException` (meh) or `HttpResponseException`?

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/204/files#r7653827

Re: [jclouds] JCLOUDS-373: Fix SoftLayerOrderItemDuplicateException. (#204)

Posted by Andrew Phillips <no...@github.com>.
Committed to [master](https://git-wip-us.apache.org/repos/asf?p=jclouds.git;a=commit;h=55b21b64494546d268df6044f5a5fecd23efba83) and [1.6.x](https://git-wip-us.apache.org/repos/asf?p=jclouds.git;a=commit;h=844819d8b7fc674010952339ef1b26ed15d3c7cd). Thanks, @andreaturli and @nacx!

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/204#issuecomment-28478078

Re: [jclouds] JCLOUDS-373: Fix SoftLayerOrderItemDuplicateException. (#204)

Posted by CloudBees pull request builder plugin <no...@github.com>.
[jclouds-pull-requests #397](https://jclouds.ci.cloudbees.com/job/jclouds-pull-requests/397/) SUCCESS
This pull request looks good

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/204#issuecomment-28475941

Re: [jclouds] JCLOUDS-373: Fix SoftLayerOrderItemDuplicateException. (#204)

Posted by Andrea Turli <no...@github.com>.
> @@ -16,7 +16,7 @@
>   */
>  package org.jclouds.softlayer.exceptions;
>  
> -public class SoftLayerOrderItemDuplicateException extends RuntimeException {
> +public class SoftLayerOrderItemDuplicateException extends IllegalStateException {

I agree with @demobox as well but @nacx the invoked method is [propagateIfPossible(https://github.com/jclouds/jclouds/blob/master/core/src/main/java/org/jclouds/util/Throwables2.java#L130) which behaves differently if the exception contains in its cause chain an IllegalStateException or a RuntimeException.
In fact RuntimeException is not considered on the loop so the throwable returned by
```Throwable throwable = Throwables2.getFirstThrowableOfType(exception, propagatableExceptionType);```
is HttpResponseException, which makes pointless the try/catch in the code as it is catching a SoftLayerOrderItemDuplicateException and not an HttpResponseException.

Makes more sense?


---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/204/files#r7652895

Re: [jclouds] JCLOUDS-373: Fix SoftLayerOrderItemDuplicateException. (#204)

Posted by CloudBees pull request builder plugin <no...@github.com>.
[jclouds-java-7-pull-requests #860](https://jclouds.ci.cloudbees.com/job/jclouds-java-7-pull-requests/860/) SUCCESS
This pull request looks good

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/204#issuecomment-28475966

Re: [jclouds] JCLOUDS-373: Fix SoftLayerOrderItemDuplicateException. (#204)

Posted by Ignasi Barrera <no...@github.com>.
> @@ -16,7 +16,7 @@
>   */
>  package org.jclouds.softlayer.exceptions;
>  
> -public class SoftLayerOrderItemDuplicateException extends RuntimeException {
> +public class SoftLayerOrderItemDuplicateException extends IllegalStateException {

Agree with @demobox.

Could you detail a bit more what exactly is going wrong when your exception extends directly from `RuntimeException`? In the end, an `IllegalStateException` is also a `RuntimeException`, so it should be propagated the same way.

When the target server returns an error code, the [error handlers and retry handlers are invoked](https://github.com/jclouds/jclouds/blob/master/core/src/main/java/org/jclouds/http/internal/BaseHttpCommandExecutorService.java#L149-L154), to put the appropriate exception in place. Once the request should not be retried again, the [exception is propagated](https://github.com/jclouds/jclouds/blob/master/core/src/main/java/org/jclouds/http/internal/BaseHttpCommandExecutorService.java#L171). This is where the `propagateifInstanceOf` is invoked, but as both exceptions are `RuntimeExceptions` there should be no difference.

Could you please details the unexpected behavior you are experiencing?

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/204/files#r7652704

Re: [jclouds] JCLOUDS-373: Fix SoftLayerOrderItemDuplicateException. (#204)

Posted by Ignasi Barrera <no...@github.com>.
> @@ -16,7 +16,7 @@
>   */
>  package org.jclouds.softlayer.exceptions;
>  
> -public class SoftLayerOrderItemDuplicateException extends RuntimeException {
> +public class SoftLayerOrderItemDuplicateException extends IllegalStateException {

I'd rather extend `HttpResponseException`, I think is semantically more correct.

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/204/files#r7654497

Re: [jclouds] JCLOUDS-373: Fix SoftLayerOrderItemDuplicateException. (#204)

Posted by Andrea Turli <no...@github.com>.
> @@ -16,7 +16,7 @@
>   */
>  package org.jclouds.softlayer.exceptions;
>  
> -public class SoftLayerOrderItemDuplicateException extends RuntimeException {
> +public class SoftLayerOrderItemDuplicateException extends IllegalStateException {

I'm ok with `IllegalArgumentException` as a quick win (mergeable today on 1.6.x?) and then we can revisit it based on the ongoing discussion on ML. wdyt?  

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/204/files#r7654177

Re: [jclouds] JCLOUDS-373: Fix SoftLayerOrderItemDuplicateException. (#204)

Posted by Andrew Phillips <no...@github.com>.
> @@ -16,7 +16,7 @@
>   */
>  package org.jclouds.softlayer.exceptions;
>  
> -public class SoftLayerOrderItemDuplicateException extends RuntimeException {
> +public class SoftLayerOrderItemDuplicateException extends IllegalStateException {

Same question as before on this: the [Javadoc for ISE](http://docs.oracle.com/javase/7/docs/api/java/lang/IllegalStateException.html) states:

"Signals that a method has been invoked at an illegal or inappropriate time. In other words, the Java environment or Java application is not in an appropriate state for the requested operation."

But where this exception is thrown (and caught) in this code, the state of the "Java environment or Java application" is perfectly OK - it's the _target server_ that has a problem.

So I don't think this is the appropriate exception type to use here.

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/204/files#r7647046

Re: [jclouds] JCLOUDS-373: Fix SoftLayerOrderItemDuplicateException. (#204)

Posted by CloudBees pull request builder plugin <no...@github.com>.
[jclouds-pull-requests #396](https://jclouds.ci.cloudbees.com/job/jclouds-pull-requests/396/) SUCCESS
This pull request looks good

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/204#issuecomment-28449130

Re: [jclouds] JCLOUDS-373: Fix SoftLayerOrderItemDuplicateException. (#204)

Posted by Ignasi Barrera <no...@github.com>.
> @@ -16,7 +16,7 @@
>   */
>  package org.jclouds.softlayer.exceptions;
>  
> -public class SoftLayerOrderItemDuplicateException extends RuntimeException {
> +public class SoftLayerOrderItemDuplicateException extends IllegalStateException {

Oh, I see now. Thanks @andreaturli. So the exception is propagated first where I mentioned, but is catched afterward in the invocation proxy to make sure a proper exception is propagated, to keep the exception model tiny and consistent.

The problem here is that there are [a few exceptions considered](https://github.com/jclouds/jclouds/blob/master/core/src/main/java/org/jclouds/util/Throwables2.java#L138-L141) as the top-level exceptions jclouds propagates, but those are not flexible enough for the custom to let the providers throw controlled exceptions generated in the error handlers.

In my opinion it would be a good idea to create a new `ProviderException` (or similar) in jclouds, that all providers willing to propagate custom controlled exceptions could extend. This will help keeping the exception model in jclouds small, allowing the error handlers to define a custom exception set.

This is quite a relevant change, so I think it is a good discussion have in the mailing list.

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/204/files#r7653115

Re: [jclouds] JCLOUDS-373: Fix SoftLayerOrderItemDuplicateException. (#204)

Posted by CloudBees pull request builder plugin <no...@github.com>.
[jclouds-java-7-pull-requests #859](https://jclouds.ci.cloudbees.com/job/jclouds-java-7-pull-requests/859/) SUCCESS
This pull request looks good

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/204#issuecomment-28449666