-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provide better exception when connection limit reached in LimitingCon… (
#2454) Motivation: Before this change, when the LimitingConnectionFactoryFilter does not allow more connections for a given host, a generic ConnectException is returned. Developer productivity can be improved since at the moment the user needs to inspect the text message for further information and to distinguish different failure cases. Modifications: This changeset subclasses the ConnectException for backwards compatibility and returns a ConnectionLimitReachedException instead. The actual message is also preserved for compatibility reasons. Result: Better user experience when matching on the exception instance while still being backwards compatible.
- Loading branch information
Showing
3 changed files
with
48 additions
and
9 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
...k-client-api/src/main/java/io/servicetalk/client/api/ConnectionLimitReachedException.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,38 @@ | ||
/* | ||
* Copyright © 2022 Apple Inc. and the ServiceTalk project authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.servicetalk.client.api; | ||
|
||
import java.net.ConnectException; | ||
|
||
/** | ||
* Thrown when the number of connections reached their limit for a given resource (i.e. a host) | ||
* depending on the context. | ||
* | ||
* @see LimitingConnectionFactoryFilter | ||
*/ | ||
public class ConnectionLimitReachedException extends ConnectException { | ||
|
||
private static final long serialVersionUID = 645105614301638032L; | ||
|
||
/** | ||
* Creates a new instance. | ||
* | ||
* @param message the detail message. | ||
*/ | ||
public ConnectionLimitReachedException(final String message) { | ||
super(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
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