Skip to content

Commit 181b79a

Browse files
authored
Merge pull request #175 from cinovo/cloudconductorpropertyproviderfix
better error handling in CloudconductorPropertyProvider
2 parents b52314b + bfed233 commit 181b79a

File tree

2 files changed

+19
-20
lines changed

2 files changed

+19
-20
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
* Swagger 2.2.40
1818
* Velocity Engine 2.4.1
1919
* Fixing DaemonExceptionMapper
20+
* Better error handling in CloudconductorPropertyProvider
2021
* Fixed vulnerabilities: CVE-2024-13009(Jetty), CVE-2025-23184(Apache CXF), CVE-2024-57699 (Json-smart),CVE-2025-27533 (ActiveMQ)
2122

2223
# 1.37

daemon/src/main/java/de/taimos/daemon/properties/CloudConductorPropertyProvider.java

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
*/
2222

2323
import java.io.File;
24-
import java.io.FileInputStream;
2524
import java.io.IOException;
2625
import java.io.InputStream;
26+
import java.nio.file.Files;
2727
import java.util.Properties;
2828

2929
import de.taimos.daemon.DaemonStarter;
@@ -73,32 +73,25 @@ public CloudConductorPropertyProvider(String server, String template, String tok
7373
}
7474

7575
private void checkSecureConnections() {
76-
String secureConnection = CloudConductorPropertyProvider.getProperty(CloudConductorPropertyProvider.CLOUDCONDUCTOR_SECURE_CONNECTIONS);
77-
if (Boolean.parseBoolean(secureConnection)){
78-
this.setProtocol(CloudConductorPropertyProvider.HTTPS);
76+
String secureConnection = System.getProperty(CloudConductorPropertyProvider.CLOUDCONDUCTOR_SECURE_CONNECTIONS);
77+
if (secureConnection == null) {
78+
secureConnection = System.getenv(CloudConductorPropertyProvider.CLOUDCONDUCTOR_SECURE_CONNECTIONS);
7979
}
80-
}
81-
82-
private static String getProperty(String name) {
83-
String property = System.getProperty(name);
84-
if(property == null) {
85-
property = System.getenv(name);
80+
if (Boolean.parseBoolean(secureConnection)) {
81+
this.setProtocol(CloudConductorPropertyProvider.HTTPS);
8682
}
87-
return property;
8883
}
8984

90-
/**
91-
* @param protocol http or https, http is default;
92-
* @return this provider
93-
*/
94-
public CloudConductorPropertyProvider setProtocol(String protocol) {
85+
/**
86+
* @param protocol http or https, http is default;
87+
*/
88+
public void setProtocol(String protocol) {
9589
if(protocol.equalsIgnoreCase(CloudConductorPropertyProvider.HTTPS)) {
9690
this.protocol = CloudConductorPropertyProvider.HTTPS;
9791
} else {
9892
this.protocol = "http";
9993
}
100-
return this;
101-
}
94+
}
10295

10396
@Override
10497
protected String getDescription() {
@@ -113,7 +106,12 @@ protected HTTPResponse getResponse() {
113106
if(this.jwt != null) {
114107
req.authBearer(this.jwt);
115108
}
116-
return req.get();
109+
HTTPResponse httpResponse = req.get();
110+
int status = httpResponse.getStatus();
111+
if (200 > status || 300 < status) {
112+
this.logger.warn("Config request with CloudConductor Server {} failed with status {}", this.server, status);
113+
}
114+
return httpResponse;
117115
}
118116

119117
private void readPropertyFile(String propFile) {
@@ -125,7 +123,7 @@ private void readPropertyFile(String propFile) {
125123
file = new File(CloudConductorPropertyProvider.CLOUDCONDUCTOR_PROP_FILE_DEFAULT_PATH);
126124
}
127125
if(file.exists()) {
128-
try(InputStream reader = new FileInputStream(file)) {
126+
try(InputStream reader = Files.newInputStream(file.toPath())) {
129127
Properties prop = new Properties();
130128
prop.load(reader);
131129
if(this.server == null && prop.containsKey(CloudConductorPropertyProvider.CLOUDCONDUCTOR_URL)) {

0 commit comments

Comments
 (0)