-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #580 from swisspost/develop
PR for Release
- Loading branch information
Showing
79 changed files
with
800 additions
and
235 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
...en-core/src/main/java/org/swisspush/gateleen/core/exception/GateleenExceptionFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package org.swisspush.gateleen.core.exception; | ||
|
||
import io.vertx.core.eventbus.ReplyException; | ||
import io.vertx.core.eventbus.ReplyFailure; | ||
|
||
|
||
/** | ||
* Applies dependency inversion for exception instantiation. | ||
* | ||
* This class did arise because we had different use cases in different | ||
* applications. One of them has the need to perform fine-grained error | ||
* reporting. Whereas in the other application this led to performance issues. | ||
* So now through this abstraction, both applications can choose the behavior | ||
* they need. | ||
* | ||
* There are two default options an app can use (if it does not want to provide | ||
* a custom impl). | ||
* One is {@link GateleenThriftyExceptionFactory}. It trades maintainability | ||
* for speed. For example prefers lightweight exceptions without stacktrace | ||
* recording. Plus it may apply other tricks to reduce resource costs. | ||
* The other one is {@link GateleenWastefulExceptionFactory}. It trades speed | ||
* for maintainability. So it tries to track as much error details as possible. | ||
* For example recording stack traces, keeping 'cause' and 'suppressed' | ||
* exceptions, plus maybe more. | ||
* | ||
* If none of those defaults matches, an app can provide its custom | ||
* implementation via dependency injection. | ||
*/ | ||
public interface GateleenExceptionFactory { | ||
|
||
/** Convenience overload for {@link #newException(String, Throwable)}. */ | ||
public default Exception newException(String msg){ return newException(msg, null); } | ||
|
||
/** Convenience overload for {@link #newException(String, Throwable)}. */ | ||
public default Exception newException(Throwable cause){ return newException(null, cause); } | ||
|
||
public Exception newException(String msg, Throwable cause); | ||
|
||
public ReplyException newReplyException(ReplyFailure failureType, int failureCode, String message); | ||
|
||
|
||
/** | ||
* See {@link GateleenThriftyExceptionFactory}. | ||
*/ | ||
public static GateleenExceptionFactory newGateleenThriftyExceptionFactory() { | ||
return new GateleenThriftyExceptionFactory(); | ||
} | ||
|
||
/** | ||
* See {@link GateleenWastefulExceptionFactory}. | ||
*/ | ||
public static GateleenExceptionFactory newGateleenWastefulExceptionFactory() { | ||
return new GateleenWastefulExceptionFactory(); | ||
} | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
...re/src/main/java/org/swisspush/gateleen/core/exception/GateleenNoStackReplyException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package org.swisspush.gateleen.core.exception; | ||
|
||
import io.vertx.core.eventbus.ReplyFailure; | ||
|
||
/** | ||
* There was once a fix in vertx for this (https://github.com/eclipse-vertx/vert.x/issues/4840) | ||
* but for whatever reason in our case we still see stack-trace recordings. Passing | ||
* this subclass to {@link io.vertx.core.eventbus.Message#reply(Object)} seems to | ||
* do the trick. | ||
*/ | ||
public class GateleenNoStackReplyException extends io.vertx.core.eventbus.ReplyException { | ||
|
||
public GateleenNoStackReplyException(ReplyFailure failureType, int failureCode, String message) { | ||
super(failureType, failureCode, message); | ||
} | ||
|
||
public GateleenNoStackReplyException(ReplyFailure failureType, String message) { | ||
this(failureType, -1, message); | ||
} | ||
|
||
public GateleenNoStackReplyException(ReplyFailure failureType) { | ||
this(failureType, -1, null); | ||
} | ||
|
||
@Override | ||
public Throwable fillInStackTrace() { | ||
return this; | ||
} | ||
|
||
} |
28 changes: 28 additions & 0 deletions
28
...re/src/main/java/org/swisspush/gateleen/core/exception/GateleenNoStacktraceException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package org.swisspush.gateleen.core.exception; | ||
|
||
/** | ||
* Basically same as in vertx, But adding the forgotten contructors. | ||
*/ | ||
public class GateleenNoStacktraceException extends RuntimeException { | ||
|
||
public GateleenNoStacktraceException() { | ||
} | ||
|
||
public GateleenNoStacktraceException(String message) { | ||
super(message); | ||
} | ||
|
||
public GateleenNoStacktraceException(String message, Throwable cause) { | ||
super(message, cause); | ||
} | ||
|
||
public GateleenNoStacktraceException(Throwable cause) { | ||
super(cause); | ||
} | ||
|
||
@Override | ||
public Throwable fillInStackTrace() { | ||
return this; | ||
} | ||
|
||
} |
24 changes: 24 additions & 0 deletions
24
.../src/main/java/org/swisspush/gateleen/core/exception/GateleenThriftyExceptionFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package org.swisspush.gateleen.core.exception; | ||
|
||
import io.vertx.core.eventbus.ReplyException; | ||
import io.vertx.core.eventbus.ReplyFailure; | ||
|
||
/** | ||
* See {@link GateleenExceptionFactory} for details. | ||
*/ | ||
class GateleenThriftyExceptionFactory implements GateleenExceptionFactory { | ||
|
||
GateleenThriftyExceptionFactory() { | ||
} | ||
|
||
public Exception newException(String message, Throwable cause) { | ||
if (cause instanceof Exception) return (Exception) cause; | ||
return new GateleenNoStacktraceException(message, cause); | ||
} | ||
|
||
@Override | ||
public ReplyException newReplyException(ReplyFailure failureType, int failureCode, String message) { | ||
return new GateleenNoStackReplyException(failureType, failureCode, message); | ||
} | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
...src/main/java/org/swisspush/gateleen/core/exception/GateleenWastefulExceptionFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package org.swisspush.gateleen.core.exception; | ||
|
||
import io.vertx.core.eventbus.ReplyException; | ||
import io.vertx.core.eventbus.ReplyFailure; | ||
|
||
/** | ||
* See {@link GateleenExceptionFactory} for details. | ||
*/ | ||
class GateleenWastefulExceptionFactory implements GateleenExceptionFactory { | ||
|
||
GateleenWastefulExceptionFactory() { | ||
} | ||
|
||
public Exception newException(String message, Throwable cause) { | ||
return new Exception(message, cause); | ||
} | ||
|
||
@Override | ||
public ReplyException newReplyException(ReplyFailure failureType, int failureCode, String message) { | ||
return new ReplyException(failureType, failureCode, message); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.