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

[SDCISA-13736, SDCISA-10974] Fix bad habits in EventBusResourceStorage. #540

Merged
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
public class EventBusResourceStorage implements ResourceStorage {

private static final Logger log = LoggerFactory.getLogger(EventBusResourceStorage.class);
private EventBus eventBus;
private String address;
private final EventBus eventBus;
private final String address;

public EventBusResourceStorage(EventBus eventBus, String address) {
this.eventBus = eventBus;
Expand All @@ -34,14 +34,16 @@

eventBus.request(address, request, (Handler<AsyncResult<Message<Buffer>>>) message -> {
if (message.failed()) {
log.warn("Got failed msg from event bus while GET. Lets run into NPE now.", message.cause());
log.warn("Got failed msg from event bus while GET. Lets run into NPE now.", new Exception("stacktrace", message.cause()));

Check warning on line 37 in gateleen-core/src/main/java/org/swisspush/gateleen/core/storage/EventBusResourceStorage.java

View check run for this annotation

Codecov / codecov/patch

gateleen-core/src/main/java/org/swisspush/gateleen/core/storage/EventBusResourceStorage.java#L37

Added line #L37 was not covered by tests
// Would be best to stop processing now. But we don't to keep backward
// compatibility (Will run into NPE anyway).
}
Buffer buffer = message.result().body();
int headerLength = buffer.getInt(0);
JsonObject header1 = new JsonObject(buffer.getString(4, headerLength + 4));
if (header1.getInteger("statusCode") == 200) {
Integer statusCode = header1.getInteger("statusCode");

Check warning on line 44 in gateleen-core/src/main/java/org/swisspush/gateleen/core/storage/EventBusResourceStorage.java

View check run for this annotation

Codecov / codecov/patch

gateleen-core/src/main/java/org/swisspush/gateleen/core/storage/EventBusResourceStorage.java#L44

Added line #L44 was not covered by tests
if( statusCode == null ) log.debug("getInteger(\"statusCode\") -> null");
if( statusCode != null && statusCode == 200 ){
bodyHandler.handle(buffer.getBuffer(4 + headerLength, buffer.length()));
} else {
bodyHandler.handle(null);
Expand All @@ -56,7 +58,8 @@
request.setInt(0, header.length()).appendBuffer(header).appendBuffer(buffer);
eventBus.request(address, request, (Handler<AsyncResult<Message<Buffer>>>) message -> {
if (message.failed()) {
log.warn("Got failed msg from event bus while PUT. Lets run into NPE now.", message.cause());
log.warn("Got failed msg from event bus while PUT. Lets run into NPE now.",
new Exception("stacktrace", message.cause()));

Check warning on line 62 in gateleen-core/src/main/java/org/swisspush/gateleen/core/storage/EventBusResourceStorage.java

View check run for this annotation

Codecov / codecov/patch

gateleen-core/src/main/java/org/swisspush/gateleen/core/storage/EventBusResourceStorage.java#L61-L62

Added lines #L61 - L62 were not covered by tests
// Would be best to stop processing now. But we don't to keep backward
// compatibility (Will run into NPE anyway).
}
Expand All @@ -79,7 +82,8 @@
request.setInt(0, header.length()).appendBuffer(header);
eventBus.request(address, request, (Handler<AsyncResult<Message<Buffer>>>) message -> {
if (message.failed()) {
log.warn("Got failed msg from event bus while DELETE. Lets run into NPE now.", message.cause());
log.warn("Got failed msg from event bus while DELETE. Lets run into NPE now.",
new Exception("stacktrace", message.cause()));

Check warning on line 86 in gateleen-core/src/main/java/org/swisspush/gateleen/core/storage/EventBusResourceStorage.java

View check run for this annotation

Codecov / codecov/patch

gateleen-core/src/main/java/org/swisspush/gateleen/core/storage/EventBusResourceStorage.java#L85-L86

Added lines #L85 - L86 were not covered by tests
// Would be best to stop processing now. But we don't to keep backward
// compatibility (Will run into NPE anyway).
}
Expand Down