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

Make OCPP library compatible with Android 8 #116

Merged
merged 1 commit into from
May 7, 2020
Merged
Show file tree
Hide file tree
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 @@ -36,7 +36,14 @@ public class AsyncPromiseFulfillerDecorator implements PromiseFulfiller {
@Override
public void fulfill(
CompletableFuture<Confirmation> promise, SessionEvents eventHandler, Request request) {
new Thread(() -> promiseFulfiller.fulfill(promise, eventHandler, request)).start();
new Thread(
new Runnable() {
@Override
public void run() {
promiseFulfiller.fulfill(promise, eventHandler, request);
}
})
.start();
}

public AsyncPromiseFulfillerDecorator(PromiseFulfiller promiseFulfiller) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ of this software and associated documentation files (the "Software"), to deal
import com.sun.net.httpserver.HttpServer;
import eu.chargetime.ocpp.model.SOAPHostInfo;
import eu.chargetime.ocpp.model.SessionInformation;
import eu.chargetime.ocpp.utilities.TimeoutHandler;
import eu.chargetime.ocpp.utilities.TimeoutTimer;
import java.io.IOException;
import java.net.InetSocketAddress;
Expand Down Expand Up @@ -121,9 +122,12 @@ public SOAPMessage incomingRequest(SOAPMessageInfo messageInfo) {
TimeoutTimer timeoutTimer =
new TimeoutTimer(
INITIAL_TIMEOUT,
() -> {
session.close();
chargeBoxes.remove(identity);
new TimeoutHandler() {
@Override
public void timeout() {
session.close();
chargeBoxes.remove(identity);
}
});

// TODO: Decorator created but not used
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,14 @@ void sendRequest(SOAPMessage message) throws NotConnectedException {
if (!connected) throw new NotConnectedException();

new Thread(
() -> {
try {
events.receivedMessage(soapConnection.call(message, url));
} catch (SOAPException e) {
disconnect();
new Runnable() {
@Override
public void run() {
try {
events.receivedMessage(soapConnection.call(message, url));
} catch (SOAPException e) {
disconnect();
}
}
})
.start();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,16 @@ protected void sendRequest(final SOAPMessage message) throws NotConnectedExcepti
if (!connected) throw new NotConnectedException();
Thread thread =
new Thread(
() -> {
try {
SOAPMessage response = soapConnection.call(message, url);
events.receivedMessage(response);
} catch (SOAPException e) {
logger.warn("sendRequest() failed", e);
disconnect();
new Runnable() {
@Override
public void run() {
try {
SOAPMessage response = soapConnection.call(message, url);
events.receivedMessage(response);
} catch (SOAPException e) {
logger.warn("sendRequest() failed", e);
disconnect();
}
}
});
thread.start();
Expand Down