-
-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added .mapConnectionAborted at RSocketClientChannel
- Loading branch information
Showing
5 changed files
with
68 additions
and
26 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
services-api/src/main/java/io/scalecube/services/exceptions/ConnectionClosedException.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,40 @@ | ||
package io.scalecube.services.exceptions; | ||
|
||
import java.util.regex.Pattern; | ||
|
||
public class ConnectionClosedException extends InternalServiceException { | ||
|
||
private static final Pattern GENERIC_CONNECTION_CLOSED = | ||
Pattern.compile( | ||
"^.*(?:connection.*(?:reset|closed|abort|broken)|broken.*pipe).*$", | ||
Pattern.CASE_INSENSITIVE); | ||
|
||
public ConnectionClosedException() { | ||
super("Connection closed"); | ||
} | ||
|
||
public ConnectionClosedException(Throwable cause) { | ||
super(cause); | ||
} | ||
|
||
public ConnectionClosedException(String message) { | ||
super(message); | ||
} | ||
|
||
/** | ||
* Returns {@code true} if connection has been aborted on a tcp level by verifying error message | ||
* and matching it against predefined pattern. | ||
* | ||
* @param th error | ||
* @return {@code true} if connection has been aborted on a tcp level | ||
*/ | ||
public static boolean isConnectionClosed(Throwable th) { | ||
if (th instanceof ConnectionClosedException) { | ||
return true; | ||
} | ||
|
||
final String message = th != null ? th.getMessage() : null; | ||
|
||
return message != null && GENERIC_CONNECTION_CLOSED.matcher(message).matches(); | ||
} | ||
} |
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
12 changes: 1 addition & 11 deletions
12
services-api/src/main/java/io/scalecube/services/exceptions/MessageCodecException.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 |
---|---|---|
@@ -1,18 +1,8 @@ | ||
package io.scalecube.services.exceptions; | ||
|
||
public class MessageCodecException extends RuntimeException { | ||
public class MessageCodecException extends InternalServiceException { | ||
|
||
public MessageCodecException(String message, Throwable cause) { | ||
super(message, cause); | ||
} | ||
|
||
@Override | ||
public synchronized Throwable fillInStackTrace() { | ||
return this; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return getClass().getSimpleName() + "{errorMessage=" + getMessage() + '}'; | ||
} | ||
} |
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