This is an automated email from the ASF dual-hosted git repository.
vavrtom pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/qpid-broker-j.git
The following commit(s) were added to refs/heads/main by this push:
new 772aa2d92e QPID-8707: [Broker-J] Fix for failing EndToEndTest (#313)
772aa2d92e is described below
commit 772aa2d92e71e69e48bad1712bcce05d0b0ed6c5
Author: Daniil Kirilyuk <[email protected]>
AuthorDate: Fri Aug 1 11:02:29 2025 +0200
QPID-8707: [Broker-J] Fix for failing EndToEndTest (#313)
---
.../qpid/disttest/jms/QpidRestAPIQueueCreator.java | 57 +++++++++++++---------
1 file changed, 33 insertions(+), 24 deletions(-)
diff --git
a/perftests/src/main/java/org/apache/qpid/disttest/jms/QpidRestAPIQueueCreator.java
b/perftests/src/main/java/org/apache/qpid/disttest/jms/QpidRestAPIQueueCreator.java
index 618230b517..053910885e 100644
---
a/perftests/src/main/java/org/apache/qpid/disttest/jms/QpidRestAPIQueueCreator.java
+++
b/perftests/src/main/java/org/apache/qpid/disttest/jms/QpidRestAPIQueueCreator.java
@@ -50,12 +50,13 @@ import org.apache.hc.client5.http.impl.auth.BasicAuthCache;
import org.apache.hc.client5.http.impl.auth.BasicCredentialsProvider;
import org.apache.hc.client5.http.impl.auth.BasicScheme;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
-import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
import org.apache.hc.client5.http.impl.classic.HttpClients;
import org.apache.hc.client5.http.protocol.HttpClientContext;
+import org.apache.hc.core5.http.ClassicHttpResponse;
import org.apache.hc.core5.http.ContentType;
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.ProtocolVersion;
+import org.apache.hc.core5.http.io.HttpClientResponseHandler;
import org.apache.hc.core5.http.io.entity.StringEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -290,30 +291,9 @@ public class QpidRestAPIQueueCreator implements
QueueCreator
{
try (final CloseableHttpClient httpClient = HttpClients.custom()
.setDefaultCredentialsProvider(_credentialsProvider)
- .build();
- final CloseableHttpResponse response =
httpClient.execute(_management, httpRequest, context, reply ->
(CloseableHttpResponse) reply))
+ .build())
{
- final int status = response.getCode();
- final ProtocolVersion version = response.getVersion();
- final String reason = response.getReasonPhrase();
- if (status != 200 && status != 201)
- {
- final String msg = String.format("Failed: HTTP error code: %d,
Version: %s, Reason: %s", status, version, reason);
- throw new RuntimeException(msg);
- }
-
- if (response.getEntity() != null)
- {
- try (ByteArrayOutputStream bos = new ByteArrayOutputStream())
- {
- response.getEntity().writeTo(bos);
- if (bos.size() > 0)
- {
- return new ObjectMapper().readValue(bos.toByteArray(),
Object.class);
- }
- }
- }
- return null;
+ return httpClient.execute(_management, httpRequest, context, new
ResponseHandler());
}
catch (IOException e)
{
@@ -342,4 +322,33 @@ public class QpidRestAPIQueueCreator implements
QueueCreator
credentialsProvider.setCredentials(authScope, new
UsernamePasswordCredentials(managementUser, managementPassword.toCharArray()));
return credentialsProvider;
}
+
+ static class ResponseHandler implements HttpClientResponseHandler<Object>
+ {
+ @Override
+ public Object handleResponse(ClassicHttpResponse response) throws
IOException
+ {
+ final int status = response.getCode();
+ final ProtocolVersion version = response.getVersion();
+ final String reason = response.getReasonPhrase();
+ if (status != 200 && status != 201)
+ {
+ final String msg = String.format("Failed: HTTP error code: %d,
Version: %s, Reason: %s", status, version, reason);
+ throw new RuntimeException(msg);
+ }
+
+ if (response.getEntity() != null)
+ {
+ try (ByteArrayOutputStream bos = new ByteArrayOutputStream())
+ {
+ response.getEntity().writeTo(bos);
+ if (bos.size() > 0)
+ {
+ return new ObjectMapper().readValue(bos.toByteArray(),
Object.class);
+ }
+ }
+ }
+ return null;
+ }
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]