Skip to content

Commit

Permalink
Merge pull request #116 from robert-s-ubi/master
Browse files Browse the repository at this point in the history
Make OCPP library compatible with Android 8
  • Loading branch information
TVolden authored May 7, 2020
2 parents 72c0f61 + 5366426 commit 0a55207
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 16 deletions.
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

0 comments on commit 0a55207

Please sign in to comment.