Skip to content

Commit

Permalink
fixed timing issues on get responseItem by signaling after item has
Browse files Browse the repository at this point in the history
been set not before.
  • Loading branch information
sruehl committed Jan 12, 2018
1 parent 3bd16f5 commit 5886538
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ public CompletableFuture<RESPONSE_ITEM> getResponseItem() {

protected void setResponseItem(RESPONSE_ITEM responseItem) {
Objects.requireNonNull(responseItem);
this.responseItem = responseItem;
try {
lock.lock();
responseSet.signalAll();
} finally {
lock.unlock();
}
this.responseItem = responseItem;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ Licensed to the Apache Software Foundation (ASF) under one
import org.apache.plc4x.java.api.messages.specific.TypeSafePlcReadRequest;
import org.apache.plc4x.java.api.messages.specific.TypeSafePlcWriteRequest;
import org.apache.plc4x.java.api.types.ResponseCode;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

Expand Down Expand Up @@ -271,7 +270,6 @@ void nonExistingItemPlcReadResponseGetValue() {
assertEquals(Optional.empty(), responseValue1, "Unexpected items in response items");
}

@Disabled("FIXME: timing issues")
@Test
void accessReadResponseFromRequest() throws Exception {
ReadRequestItem<Byte> readRequestItem = new ReadRequestItem<>(Byte.class, null, (byte) 0x0);
Expand All @@ -285,7 +283,6 @@ void accessReadResponseFromRequest() throws Exception {
assertEquals(readResponseItem, byteReadResponseItem);
}

@Disabled("FIXME: timing issues")
@Test
void accessWriteResponseFromRequest() throws Exception {
WriteRequestItem<Byte> writeRequestItem = new WriteRequestItem<>(Byte.class, null, (byte) 0x0);
Expand All @@ -299,7 +296,6 @@ void accessWriteResponseFromRequest() throws Exception {
assertEquals(writeResponseItem, byteWriteResponseItem);
}

@Disabled("FIXME: timing issues")
@Test
void accessResponseFromRequestMultiThreaded() throws Exception {
ReadRequestItem<Byte> readRequestItem = new ReadRequestItem<>(Byte.class, null, (byte) 0x0);
Expand All @@ -315,6 +311,7 @@ void accessResponseFromRequestMultiThreaded() throws Exception {
}
}).start();
}
assertEquals(10, failLatch.getCount());
assertEquals(10, successLatch.getCount());

ReadResponseItem<Byte> readResponseItem = new ReadResponseItem<>(readRequestItem, ResponseCode.OK, Collections.singletonList((byte) 0x0));
Expand Down

0 comments on commit 5886538

Please sign in to comment.