You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by ri...@apache.org on 2022/06/29 16:05:52 UTC

[incubator-streampipes] branch dev updated: [hotfix] Improve error message when StreamPipes core is unavailable

This is an automated email from the ASF dual-hosted git repository.

riemer pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes.git


The following commit(s) were added to refs/heads/dev by this push:
     new 389b43dc7 [hotfix] Improve error message when StreamPipes core is unavailable
389b43dc7 is described below

commit 389b43dc7c0272d5debaa498c8978b8f7de8455d
Author: Dominik Riemer <do...@gmail.com>
AuthorDate: Wed Jun 29 18:05:42 2022 +0200

    [hotfix] Improve error message when StreamPipes core is unavailable
---
 .../java/org/apache/streampipes/client/http/HttpRequest.java | 12 +++++-------
 .../client/StreamPipesClientRuntimeConnectionResolver.java   |  7 ++++---
 2 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/streampipes-client/src/main/java/org/apache/streampipes/client/http/HttpRequest.java b/streampipes-client/src/main/java/org/apache/streampipes/client/http/HttpRequest.java
index 5c11455e3..cd5d17807 100644
--- a/streampipes-client/src/main/java/org/apache/streampipes/client/http/HttpRequest.java
+++ b/streampipes-client/src/main/java/org/apache/streampipes/client/http/HttpRequest.java
@@ -74,11 +74,11 @@ public abstract class HttpRequest<SO, DSO, DT> {
     return headers.toArray(new Header[0]);
   }
 
-  protected String makeUrl() {
+  protected String makeUrl() throws SpRuntimeException {
     return makeUrl(true);
   }
 
-  protected String makeUrl(boolean includePath) {
+  protected String makeUrl(boolean includePath) throws SpRuntimeException {
     String baseUrl = clientConfig.getConnectionConfig().getBaseUrl();
     if (includePath) {
       baseUrl = baseUrl + "/" + apiPath.toString();
@@ -87,7 +87,7 @@ public abstract class HttpRequest<SO, DSO, DT> {
     return baseUrl;
   }
 
-  public DT executeRequest() throws SpRuntimeException {
+  public DT executeRequest() {
     Request request = makeRequest(serializer);
     try {
       HttpResponse response = request.execute().returnResponse();
@@ -101,10 +101,8 @@ public abstract class HttpRequest<SO, DSO, DT> {
           throw new SpRuntimeException(status.getStatusCode() + " - " + status.getReasonPhrase());
         }
       }
-    } catch (NoHttpResponseException e) {
-      throw new SpRuntimeException("Could not connect to the StreamPipes API - please check that StreamPipes is available at " + makeUrl(false));
-    } catch (IOException e) {
-      throw new SpRuntimeException(e.getMessage());
+    } catch (IOException | SpRuntimeException e) {
+      throw new SpRuntimeException("Could not connect to the StreamPipes API - please check that StreamPipes is available");
     }
   }
 
diff --git a/streampipes-service-extensions-base/src/main/java/org/apache/streampipes/service/extensions/base/client/StreamPipesClientRuntimeConnectionResolver.java b/streampipes-service-extensions-base/src/main/java/org/apache/streampipes/service/extensions/base/client/StreamPipesClientRuntimeConnectionResolver.java
index e9bf03bfe..52cf1b5fb 100644
--- a/streampipes-service-extensions-base/src/main/java/org/apache/streampipes/service/extensions/base/client/StreamPipesClientRuntimeConnectionResolver.java
+++ b/streampipes-service-extensions-base/src/main/java/org/apache/streampipes/service/extensions/base/client/StreamPipesClientRuntimeConnectionResolver.java
@@ -20,15 +20,16 @@ package org.apache.streampipes.service.extensions.base.client;
 import org.apache.streampipes.client.credentials.CredentialsProvider;
 import org.apache.streampipes.client.credentials.StreamPipesTokenCredentials;
 import org.apache.streampipes.client.model.ClientConnectionUrlResolver;
-import org.apache.streampipes.commons.constants.Envs;
 import org.apache.streampipes.commons.constants.DefaultEnvValues;
+import org.apache.streampipes.commons.constants.Envs;
+import org.apache.streampipes.commons.exceptions.SpRuntimeException;
 import org.apache.streampipes.commons.networking.Networking;
-import org.apache.streampipes.service.base.BaseNetworkingConfig;
 import org.apache.streampipes.svcdiscovery.SpServiceDiscovery;
 import org.apache.streampipes.svcdiscovery.api.model.DefaultSpServiceGroups;
 import org.apache.streampipes.svcdiscovery.api.model.DefaultSpServiceTags;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+
 import java.net.UnknownHostException;
 import java.util.Collections;
 import java.util.List;
@@ -47,7 +48,7 @@ public class StreamPipesClientRuntimeConnectionResolver implements ClientConnect
   }
 
   @Override
-  public String getBaseUrl() {
+  public String getBaseUrl() throws SpRuntimeException {
     List<String> baseUrls = findClientServices();
     if (baseUrls.size() > 0) {
       if (Envs.SP_DEBUG.exists()) {