Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

develop to master to trigger release #600

Merged
merged 18 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gateleen-cache/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.swisspush.gateleen</groupId>
<artifactId>gateleen</artifactId>
<version>2.1.8-SNAPSHOT</version>
<version>2.1.9-SNAPSHOT</version>
</parent>

<artifactId>gateleen-cache</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion gateleen-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.swisspush.gateleen</groupId>
<artifactId>gateleen</artifactId>
<version>2.1.8-SNAPSHOT</version>
<version>2.1.9-SNAPSHOT</version>
</parent>

<artifactId>gateleen-core</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion gateleen-delegate/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.swisspush.gateleen</groupId>
<artifactId>gateleen</artifactId>
<version>2.1.8-SNAPSHOT</version>
<version>2.1.9-SNAPSHOT</version>
</parent>

<artifactId>gateleen-delegate</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion gateleen-delta/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.swisspush.gateleen</groupId>
<artifactId>gateleen</artifactId>
<version>2.1.8-SNAPSHOT</version>
<version>2.1.9-SNAPSHOT</version>
</parent>

<artifactId>gateleen-delta</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion gateleen-expansion/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.swisspush.gateleen</groupId>
<artifactId>gateleen</artifactId>
<version>2.1.8-SNAPSHOT</version>
<version>2.1.9-SNAPSHOT</version>
</parent>

<artifactId>gateleen-expansion</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion gateleen-hook-js/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.swisspush.gateleen</groupId>
<artifactId>gateleen</artifactId>
<version>2.1.8-SNAPSHOT</version>
<version>2.1.9-SNAPSHOT</version>
</parent>
<artifactId>gateleen-hook-js</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion gateleen-hook/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.swisspush.gateleen</groupId>
<artifactId>gateleen</artifactId>
<version>2.1.8-SNAPSHOT</version>
<version>2.1.9-SNAPSHOT</version>
</parent>

<artifactId>gateleen-hook</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion gateleen-kafka/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.swisspush.gateleen</groupId>
<artifactId>gateleen</artifactId>
<version>2.1.8-SNAPSHOT</version>
<version>2.1.9-SNAPSHOT</version>
</parent>

<artifactId>gateleen-kafka</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import java.util.List;

import static java.lang.System.currentTimeMillis;
import static java.lang.Thread.currentThread;
import static org.slf4j.LoggerFactory.getLogger;

/**
Expand Down Expand Up @@ -52,33 +51,31 @@ class KafkaProducerRecordBuilder {
* @throws ValidationException when the payload is not valid (missing properties, wrong types, etc.)
*/
Future<List<KafkaProducerRecord<String, String>>> buildRecordsAsync(String topic, Buffer payload) {
return Future.<Void>succeededFuture().compose((Void v) -> {
return Future.<Void>succeededFuture().compose((Void v) -> vertx.executeBlocking(() -> {
long beginEpchMs = currentTimeMillis();
JsonObject payloadObj;
try {
payloadObj = new JsonObject(payload);
} catch (DecodeException de) {
return Future.failedFuture(new ValidationException("Error while parsing payload", de));
throw new ValidationException("Error while parsing payload", de);
}
JsonArray recordsArray;
try {
recordsArray = payloadObj.getJsonArray(RECORDS);
} catch (ClassCastException cce) {
return Future.failedFuture(new ValidationException("Property '" + RECORDS + "' must be of type JsonArray holding JsonObject objects"));
throw new ValidationException("Property '" + RECORDS + "' must be of type JsonArray holding JsonObject objects");
}
if (recordsArray == null) {
return Future.failedFuture(new ValidationException("Missing 'records' array"));
throw new ValidationException("Missing 'records' array");
}
return vertx.executeBlocking(() -> {
long beginEpchMs = currentTimeMillis();
List<KafkaProducerRecord<String, String>> kafkaProducerRecords = new ArrayList<>(recordsArray.size());
for (int i = 0; i < recordsArray.size(); i++) {
kafkaProducerRecords.add(fromRecordJsonObject(topic, recordsArray.getJsonObject(i)));
}
long durationMs = currentTimeMillis() - beginEpchMs;
log.debug("Serializing JSON did block thread for {}ms", durationMs);
return kafkaProducerRecords;
});
});
List<KafkaProducerRecord<String, String>> kafkaProducerRecords = new ArrayList<>(recordsArray.size());
for (int i = 0; i < recordsArray.size(); i++) {
kafkaProducerRecords.add(fromRecordJsonObject(topic, recordsArray.getJsonObject(i)));
}
long durationMs = currentTimeMillis() - beginEpchMs;
log.debug("Parsing and Serializing JSON did block thread for {}ms", durationMs);
return kafkaProducerRecords;
}));
}

/** @deprecated Use {@link #buildRecordsAsync(String, Buffer)}. */
Expand Down
2 changes: 1 addition & 1 deletion gateleen-logging/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.swisspush.gateleen</groupId>
<artifactId>gateleen</artifactId>
<version>2.1.8-SNAPSHOT</version>
<version>2.1.9-SNAPSHOT</version>
</parent>

<artifactId>gateleen-logging</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion gateleen-merge/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.swisspush.gateleen</groupId>
<artifactId>gateleen</artifactId>
<version>2.1.8-SNAPSHOT</version>
<version>2.1.9-SNAPSHOT</version>
</parent>

<artifactId>gateleen-merge</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion gateleen-monitoring/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.swisspush.gateleen</groupId>
<artifactId>gateleen</artifactId>
<version>2.1.8-SNAPSHOT</version>
<version>2.1.9-SNAPSHOT</version>
</parent>

<artifactId>gateleen-monitoring</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion gateleen-packing/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.swisspush.gateleen</groupId>
<artifactId>gateleen</artifactId>
<version>2.1.8-SNAPSHOT</version>
<version>2.1.9-SNAPSHOT</version>
</parent>

<artifactId>gateleen-packing</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion gateleen-player/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.swisspush.gateleen</groupId>
<artifactId>gateleen</artifactId>
<version>2.1.8-SNAPSHOT</version>
<version>2.1.9-SNAPSHOT</version>
</parent>

<artifactId>gateleen-player</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion gateleen-playground/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.swisspush.gateleen</groupId>
<artifactId>gateleen</artifactId>
<version>2.1.8-SNAPSHOT</version>
<version>2.1.9-SNAPSHOT</version>
</parent>

<artifactId>gateleen-playground</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion gateleen-qos/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.swisspush.gateleen</groupId>
<artifactId>gateleen</artifactId>
<version>2.1.8-SNAPSHOT</version>
<version>2.1.9-SNAPSHOT</version>
</parent>

<artifactId>gateleen-qos</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion gateleen-queue/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.swisspush.gateleen</groupId>
<artifactId>gateleen</artifactId>
<version>2.1.8-SNAPSHOT</version>
<version>2.1.9-SNAPSHOT</version>
</parent>

<artifactId>gateleen-queue</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion gateleen-routing/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.swisspush.gateleen</groupId>
<artifactId>gateleen</artifactId>
<version>2.1.8-SNAPSHOT</version>
<version>2.1.9-SNAPSHOT</version>
</parent>

<artifactId>gateleen-routing</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ private Handler<AsyncResult<HttpClientResponse>> getAsyncHttpClientResponseHandl

final LoggingWriteStream loggingWriteStream = new LoggingWriteStream(req.response(), loggingHandler, false);
final Pump pump = Pump.pump(cRes, loggingWriteStream);
cRes.endHandler(v -> {
Handler<Void> cResEndHandler = v -> {
try {
req.response().end();

Expand All @@ -516,7 +516,14 @@ private Handler<AsyncResult<HttpClientResponse>> getAsyncHttpClientResponseHandl
// ignore because maybe already closed
}
vertx.runOnContext(event -> loggingHandler.log());
});
};
try {
cRes.endHandler(cResEndHandler);
} catch (IllegalStateException ex) {
log.warn("cRes.endHandler() failed", ex);
respondError(req, StatusCode.INTERNAL_SERVER_ERROR);
return;
}
pump.start();

Runnable unpump = () -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.slf4j.LoggerFactory;
import org.swisspush.gateleen.core.configuration.ConfigurationResourceManager;
import org.swisspush.gateleen.core.configuration.ConfigurationResourceObserver;
import org.swisspush.gateleen.core.exception.GateleenExceptionFactory;
import org.swisspush.gateleen.core.http.HttpClientFactory;
import org.swisspush.gateleen.core.http.RequestLoggerFactory;
import org.swisspush.gateleen.core.logging.LoggableResource;
Expand Down Expand Up @@ -56,6 +57,7 @@ public class Router implements Refreshable, LoggableResource, ConfigurationResou
private final String rulesUri;
private final String userProfileUri;
private final String serverUri;
private final GateleenExceptionFactory exceptionFactory;
private io.vertx.ext.web.Router router;
private final LoggingResourceManager loggingResourceManager;
private final LogAppenderRepository logAppenderRepository;
Expand Down Expand Up @@ -117,6 +119,7 @@ public static RouterBuilder builder() {
HttpClientFactory httpClientFactory,
int routeMultiplier,
@Nullable OAuthProvider oAuthProvider,
GateleenExceptionFactory exceptionFactory,
Handler<Void>... doneHandlers) {
this.storage = storage;
this.properties = properties;
Expand All @@ -135,6 +138,7 @@ public static RouterBuilder builder() {
this.doneHandlers = doneHandlers;
this.routeMultiplier = routeMultiplier;
this.oAuthProvider = oAuthProvider;
this.exceptionFactory = exceptionFactory;

if (oAuthProvider != null) {
this.oAuthStrategy = new OAuthStrategy(oAuthProvider);
Expand Down Expand Up @@ -324,7 +328,7 @@ private void createForwarders(List<Rule> rules, io.vertx.ext.web.Router newRoute
vertx.eventBus());
} else if (rule.getStorage() != null) {
forwarder = new StorageForwarder(vertx.eventBus(), rule, loggingResourceManager, logAppenderRepository,
monitoringHandler);
monitoringHandler, exceptionFactory);
} else if (rule.getScheme().equals("local")) {
forwarder = new Forwarder(vertx, selfClient, rule, this.storage, loggingResourceManager, logAppenderRepository,
monitoringHandler, userProfileUri, authStrategy);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.swisspush.gateleen.core.configuration.ConfigurationResourceManager;
import org.swisspush.gateleen.core.exception.GateleenExceptionFactory;
import org.swisspush.gateleen.core.http.HttpClientFactory;
import org.swisspush.gateleen.core.storage.ResourceStorage;
import org.swisspush.gateleen.logging.LogAppenderRepository;
Expand Down Expand Up @@ -52,6 +53,7 @@ public class RouterBuilder {
private int routeMultiplier = Router.DEFAULT_ROUTER_MULTIPLIER;

private OAuthProvider oAuthProvider;
private GateleenExceptionFactory exceptionFactory;

RouterBuilder() {
// PackagePrivate, as clients should use "Router.builder()" and not this class here directly.
Expand All @@ -67,6 +69,10 @@ public Router build() {
defaultRouteTypes = all();
}

if (this.exceptionFactory == null) {
this.exceptionFactory = GateleenExceptionFactory.newGateleenThriftyExceptionFactory();
}

Handler<Void>[] doneHandlersArray;
if (doneHandlers == null || doneHandlers.isEmpty()) {
logger.debug("No doneHandlers specified.");
Expand Down Expand Up @@ -102,6 +108,7 @@ public Router build() {
httpClientFactory,
routeMultiplier,
oAuthProvider,
exceptionFactory,
doneHandlersArray
);
if (resourceLoggingEnabled) {
Expand Down Expand Up @@ -273,4 +280,9 @@ public RouterBuilder withRouteMultiplier(int routeMultiplier) {
this.routeMultiplier = routeMultiplier;
return this;
}

public RouterBuilder withExceptionFactory(GateleenExceptionFactory exceptionFactory) {
this.exceptionFactory = exceptionFactory;
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import io.vertx.ext.web.RoutingContext;
import org.slf4j.Logger;
import org.swisspush.gateleen.core.cors.CORSHandler;
import org.swisspush.gateleen.core.exception.GateleenExceptionFactory;
import org.swisspush.gateleen.core.http.HeaderFunctions;
import org.swisspush.gateleen.core.http.HttpRequest;
import org.swisspush.gateleen.core.http.RequestLoggerFactory;
Expand All @@ -40,13 +41,17 @@ public class StorageForwarder extends AbstractForwarder {
private Pattern urlPattern;
private String address;
private CORSHandler corsHandler;
private GateleenExceptionFactory gateleenExceptionFactory;

public StorageForwarder(EventBus eventBus, Rule rule, LoggingResourceManager loggingResourceManager, LogAppenderRepository logAppenderRepository, MonitoringHandler monitoringHandler) {
public StorageForwarder(EventBus eventBus, Rule rule, LoggingResourceManager loggingResourceManager,
LogAppenderRepository logAppenderRepository, MonitoringHandler monitoringHandler,
GateleenExceptionFactory gateleenExceptionFactory) {
super(rule, loggingResourceManager, logAppenderRepository, monitoringHandler);
this.eventBus = eventBus;
this.address = Address.storageAddress() + "-" + rule.getStorage();
urlPattern = Pattern.compile(rule.getUrlPattern());
corsHandler = new CORSHandler();
this.gateleenExceptionFactory = gateleenExceptionFactory;
}

@Override
Expand Down Expand Up @@ -97,7 +102,7 @@ public void handle(final RoutingContext ctx) {
response.setStatusCode(StatusCode.INTERNAL_SERVER_ERROR.getStatusCode());
response.setStatusMessage(statusMessage);
response.end();
log.error("Storage request failed", result.cause());
log.error(statusMessage, gateleenExceptionFactory.newException(result.cause()));
} else {
Buffer buffer = result.result().body();
int headerLength = buffer.getInt(0);
Expand Down
2 changes: 1 addition & 1 deletion gateleen-runconfig/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.swisspush.gateleen</groupId>
<artifactId>gateleen</artifactId>
<version>2.1.8-SNAPSHOT</version>
<version>2.1.9-SNAPSHOT</version>
</parent>

<artifactId>gateleen-runconfig</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion gateleen-scheduler/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.swisspush.gateleen</groupId>
<artifactId>gateleen</artifactId>
<version>2.1.8-SNAPSHOT</version>
<version>2.1.9-SNAPSHOT</version>
</parent>

<artifactId>gateleen-scheduler</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion gateleen-security/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.swisspush.gateleen</groupId>
<artifactId>gateleen</artifactId>
<version>2.1.8-SNAPSHOT</version>
<version>2.1.9-SNAPSHOT</version>
</parent>

<artifactId>gateleen-security</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion gateleen-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.swisspush.gateleen</groupId>
<artifactId>gateleen</artifactId>
<version>2.1.8-SNAPSHOT</version>
<version>2.1.9-SNAPSHOT</version>
</parent>
<artifactId>gateleen-test</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion gateleen-testhelper/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.swisspush.gateleen</groupId>
<artifactId>gateleen</artifactId>
<version>2.1.8-SNAPSHOT</version>
<version>2.1.9-SNAPSHOT</version>
</parent>

<artifactId>gateleen-testhelper</artifactId>
Expand Down
Loading
Loading