Skip to content

Commit 1a4c5c4

Browse files
Merge branch 'master' into bm/mc-4457
2 parents 833e5fa + 64821f9 commit 1a4c5c4

6 files changed

Lines changed: 41 additions & 20 deletions

File tree

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "4.4.0"
2+
".": "4.4.1"
33
}

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55

66
* making Annotations.fieldsAnAnnotations respect inheritance ([3b266dd](https://github.com/mxenabled/path-core/commit/3b266ddcb227766a32f16e88e7b9b2022737de53))
77

8+
## [4.4.1](https://github.com/mxenabled/path-core/compare/v4.4.0...v4.4.1) (2025-01-22)
9+
10+
11+
### Bug Fixes
12+
13+
* handle external timeout error with status code 531 ([aeba873](https://github.com/mxenabled/path-core/commit/aeba873636199969dbb42f2dde84b285bca54dc5))
14+
815
## [4.4.0](https://github.com/mxenabled/path-core/compare/v4.3.0...v4.4.0) (2025-01-14)
916

1017

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ _Gradle_
2323
<!-- x-release-please-start-version -->
2424
```groovy
2525
dependencies {
26-
api platform("com.mx.path-core:platform:4.4.0")
26+
api platform("com.mx.path-core:platform:4.4.1")
2727
2828
implementation "com.mx.path-core:common"
2929
implementation "com.mx.path-core:context"
@@ -45,16 +45,16 @@ _Gradle_
4545
<!-- x-release-please-start-version -->
4646
```groovy
4747
dependencies {
48-
implementation "com.mx.path-core:common:4.4.0"
49-
implementation "com.mx.path-core:context:4.4.0"
50-
implementation "com.mx.path-core:gateway:4.4.0"
51-
implementation "com.mx.path-core:http:4.4.0"
52-
implementation "com.mx.path-core:messaging:4.4.0"
53-
implementation "com.mx.path-core:utilities:4.4.0"
48+
implementation "com.mx.path-core:common:4.4.1"
49+
implementation "com.mx.path-core:context:4.4.1"
50+
implementation "com.mx.path-core:gateway:4.4.1"
51+
implementation "com.mx.path-core:http:4.4.1"
52+
implementation "com.mx.path-core:messaging:4.4.1"
53+
implementation "com.mx.path-core:utilities:4.4.1"
5454
55-
annotationProcessor "com.mx.path-core:gateway-generator:4.4.0"
55+
annotationProcessor "com.mx.path-core:gateway-generator:4.4.1"
5656
57-
testImplementation "com.mx.path-core:testing:4.4.0"
57+
testImplementation "com.mx.path-core:testing:4.4.1"
5858
}
5959
```
6060
<!-- x-release-please-end -->

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ plugins {
77
id "io.github.gradle-nexus.publish-plugin" version "1.1.0"
88
}
99

10-
version "4.4.0" // x-release-please-version
10+
version "4.4.1" // x-release-please-version
1111

1212
def platformProject = "platform"
1313
def publishedProjects = [

http/src/main/java/com/mx/path/connect/http/HttpClientFilter.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
import org.apache.http.client.entity.UrlEncodedFormEntity;
4545
import org.apache.http.client.methods.RequestBuilder;
4646
import org.apache.http.client.utils.URIBuilder;
47-
import org.apache.http.conn.ConnectTimeoutException;
4847
import org.apache.http.conn.HttpHostConnectException;
4948
import org.apache.http.conn.ssl.NoopHostnameVerifier;
5049
import org.apache.http.entity.ByteArrayEntity;
@@ -68,7 +67,6 @@ public class HttpClientFilter extends RequestFilterBase {
6867
* instead of converting it to a String.
6968
*/
7069
private static final List<String> RAW_BODY_CONTENT_TYPE_HINTS = Arrays.asList("image", "pdf", "msword");
71-
private static final int HTTP_STATUS_EXTERNAL_TIMEOUT = 531;
7270

7371
private static GsonBuilder gsonBuilder = new GsonBuilder();
7472
private static final Gson GSON = gsonBuilder
@@ -161,15 +159,12 @@ public final void execute(Request request, Response response) {
161159
} finally {
162160
response.finish();
163161
}
164-
} catch (ConnectTimeoutException e) {
165-
httpResponse.setStatus(HttpStatus.valueOf(HTTP_STATUS_EXTERNAL_TIMEOUT));
166-
throw new ConnectException("Connection timeout: " + e.getMessage(), e);
162+
} catch (ConnectException e) {
163+
throw new HttpClientConnectException("Connection Exception", e);
167164
} catch (SocketTimeoutException e) {
168-
httpResponse.setStatus(HttpStatus.valueOf(HTTP_STATUS_EXTERNAL_TIMEOUT));
169-
throw new ConnectException("Read timeout: " + e.getMessage(), e);
165+
throw new HttpClientConnectException("Read Timeout Exception", e);
170166
} catch (NoHttpResponseException e) {
171-
httpResponse.setStatus(HttpStatus.valueOf(HTTP_STATUS_EXTERNAL_TIMEOUT));
172-
throw new ConnectException("Target server failed to respond: " + e.getMessage(), e);
167+
throw new HttpClientConnectException("Target server failed to response", e);
173168
} catch (SSLHandshakeException e) {
174169
throw new HttpClientConnectException("SSL handshake failed", e);
175170
} catch (SSLException e) {

http/src/test/groovy/com/mx/path/api/connect/http/HttpClientFilterTest.groovy

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import com.mx.path.connect.http.HttpClientFilter
88
import com.mx.path.connect.http.HttpRequest
99
import com.mx.path.connect.http.HttpResponse
1010
import com.mx.path.core.common.collection.MultiValueMap
11+
import com.mx.path.core.common.connect.ConnectException
1112
import com.mx.path.core.common.connect.Request
1213
import com.mx.path.core.common.connect.RequestFilter
1314

@@ -111,4 +112,22 @@ class HttpClientFilterTest extends Specification {
111112
false || makeContentTypeHeaders("application/xml")
112113
false || makeContentTypeHeaders()
113114
}
115+
116+
def "test connect exception handling in execute method"() {
117+
given: "A mock HttpRequest and Response"
118+
def mockRequest = Mock(HttpRequest)
119+
def mockResponse = Mock(HttpResponse)
120+
121+
// Create the real executor object (HttpClientFilter)
122+
HttpClientFilter executor = Mock(HttpClientFilter)
123+
124+
executor.execute(mockRequest, mockResponse) >> { throw new ConnectException("Connection Exception") }
125+
126+
when: "Execute method is called"
127+
executor.execute(mockRequest, mockResponse)
128+
129+
then: "ConnectException is thrown"
130+
thrown(ConnectException)
131+
}
132+
114133
}

0 commit comments

Comments
 (0)