Skip to content

Commit 256252c

Browse files
committed
try to make it work v99
Signed-off-by: christian.lutnik <[email protected]>
1 parent a89d6f2 commit 256252c

File tree

6 files changed

+40
-234
lines changed

6 files changed

+40
-234
lines changed

.github/workflows/pullrequest.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ jobs:
4242
${{ runner.os }}${{ matrix.build.java }}-maven-
4343
4444
- name: Verify with Maven
45-
run: mvn --batch-mode --update-snapshots -e -X --activate-profiles e2e,${{ matrix.build.profile }} verify
45+
run: mvn --batch-mode --update-snapshots --activate-profiles e2e,${{ matrix.build.profile }} verify
4646

4747
- name: Verify with vmlens
48-
run: mvn vmlens-maven-plugin:test -e -X --activate-profiles vmlens
48+
run: mvn vmlens-maven-plugin:test
4949

5050
- if: matrix.build.java == '17'
5151
name: Upload coverage to Codecov

pom.xml

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,14 @@
7777
<version>1.4.1</version>
7878
<scope>test</scope>
7979
</dependency>
80-
<!--
81-
<dependency>
82-
<groupId>org.mockito</groupId>
83-
<artifactId>mockito-core</artifactId>
84-
<version>${org.mockito.version}</version>
85-
<scope>test</scope>
86-
</dependency>
87-
-->
80+
81+
<dependency>
82+
<groupId>org.mockito</groupId>
83+
<artifactId>mockito-core</artifactId>
84+
<version>${org.mockito.version}</version>
85+
<scope>test</scope>
86+
</dependency>
87+
8888
<dependency>
8989
<groupId>org.assertj</groupId>
9090
<artifactId>assertj-core</artifactId>
@@ -167,10 +167,12 @@
167167
<version>1.37</version>
168168
<scope>test</scope>
169169
</dependency>
170+
170171
<dependency>
171172
<groupId>com.vmlens</groupId>
172173
<artifactId>api</artifactId>
173174
<version>1.2.11</version>
175+
<scope>test</scope>
174176
</dependency>
175177

176178
</dependencies>
@@ -181,7 +183,6 @@
181183
<!-- Start mockito workaround -->
182184
<!-- https://github.com/mockito/mockito/issues/3121 -->
183185
<!-- These are transitive dependencies of mockito we are forcing -->
184-
<!--
185186
<dependency>
186187
<groupId>net.bytebuddy</groupId>
187188
<artifactId>byte-buddy</artifactId>
@@ -195,7 +196,6 @@
195196
<version>1.17.7</version>
196197
<scope>test</scope>
197198
</dependency>
198-
-->
199199
<!-- End mockito workaround-->
200200

201201
<dependency>
@@ -310,8 +310,13 @@
310310
<version>1.2.11</version>
311311
<executions>
312312
<execution>
313+
<id>test</id>
314+
<goals>
315+
<goal>test</goal>
316+
</goals>
313317
<configuration>
314318
<agentDirectory>vmlens-agent</agentDirectory>
319+
<failIfNoTests>true</failIfNoTests>
315320
</configuration>
316321
</execution>
317322
</executions>

src/main/java/dev/openfeature/sdk/OpenFeatureClient.java

Lines changed: 0 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
package dev.openfeature.sdk;
22

3-
import com.vmlens.api.AllInterleavings;
43
import dev.openfeature.sdk.exceptions.ExceptionUtils;
54
import dev.openfeature.sdk.exceptions.FatalError;
65
import dev.openfeature.sdk.exceptions.GeneralError;
76
import dev.openfeature.sdk.exceptions.OpenFeatureError;
87
import dev.openfeature.sdk.exceptions.ProviderNotReadyError;
98
import dev.openfeature.sdk.internal.ObjectUtils;
10-
import dev.openfeature.sdk.providers.memory.Flag;
11-
import dev.openfeature.sdk.providers.memory.InMemoryProvider;
129
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
1310
import java.util.ArrayList;
1411
import java.util.Arrays;
@@ -18,7 +15,6 @@
1815
import java.util.Map;
1916
import java.util.Objects;
2017
import java.util.concurrent.ConcurrentLinkedQueue;
21-
import java.util.concurrent.atomic.AtomicInteger;
2218
import java.util.concurrent.atomic.AtomicReference;
2319
import java.util.function.Consumer;
2420
import lombok.Getter;
@@ -519,117 +515,4 @@ public Client removeHandler(ProviderEvent event, Consumer<EventDetails> handler)
519515
openfeatureApi.removeHandler(domain, event, handler);
520516
return this;
521517
}
522-
523-
static int jaVar = 0;
524-
525-
/**
526-
* run.
527-
*
528-
* @param args the args
529-
* @throws InterruptedException something
530-
*/
531-
public static void main(String[] args) throws InterruptedException {
532-
533-
System.out.println("OpenFeatureClientTest.testUpdate");
534-
final OpenFeatureAPI api = new OpenFeatureAPI();
535-
536-
var flags = new HashMap<String, Flag<?>>();
537-
flags.put("a", Flag.builder().variant("a", "def").defaultVariant("a").build());
538-
flags.put("b", Flag.builder().variant("a", "as").defaultVariant("a").build());
539-
flags.put("c", Flag.builder().variant("a", "dfs").defaultVariant("a").build());
540-
flags.put("d", Flag.builder().variant("a", "asddd").defaultVariant("a").build());
541-
api.setProviderAndWait(new InMemoryProvider(flags));
542-
var i = 0;
543-
var c = new AtomicInteger();
544-
545-
System.out.println("before try");
546-
try (AllInterleavings allInterleavings = new AllInterleavings("Concurrent evaluations and hook additions")) {
547-
while (allInterleavings.hasNext()) {
548-
c.incrementAndGet();
549-
jaVar = 0;
550-
Thread first = new Thread() {
551-
@Override
552-
public void run() {
553-
jaVar++;
554-
}
555-
};
556-
first.start();
557-
jaVar++;
558-
first.join();
559-
if (jaVar != 2) {
560-
throw new RuntimeException("jaVar=" + jaVar);
561-
}
562-
/*
563-
var client = api.getClient();
564-
var firstReady = new Awaitable();
565-
var secondReady = new Awaitable();
566-
var startThreads = new Awaitable();
567-
Thread first = new Thread() {
568-
@Override
569-
public void run() {
570-
firstReady.wakeup();
571-
startThreads.await();
572-
client.getStringValue("a", "a");
573-
}
574-
};
575-
Thread hookAdder = new Thread() {
576-
@Override
577-
public void run() {
578-
secondReady.wakeup();
579-
startThreads.await();
580-
client.addHooks(new Hook() {});
581-
}
582-
};
583-
hookAdder.start();
584-
first.start();
585-
firstReady.await();
586-
secondReady.await();
587-
startThreads.wakeup();
588-
first.join();
589-
hookAdder.join();
590-
*/
591-
/*System.out.println("has interlereaving");
592-
i++;
593-
//var latch = new CountDownLatch(1);
594-
var client = api.getClient();
595-
var concurrentModException = new AtomicReference<ConcurrentModificationException>();
596-
Thread eval = new Thread(() -> {
597-
System.out.println("eval");
598-
try {
599-
latch.await();
600-
} catch (InterruptedException ignored) {
601-
}
602-
client.getStringValue("a", "a");
603-
client.getStringValue("b", "a");
604-
client.getStringValue("c", "a");
605-
client.getStringValue("d", "a");
606-
607-
});
608-
Thread hookAdder = new Thread(() -> {
609-
System.out.println("hook adder");
610-
try {
611-
latch.await();
612-
} catch (InterruptedException ignored) {
613-
}
614-
client.addHooks(new Hook() {});
615-
616-
});
617-
System.out.println("starting...");
618-
//eval.start();
619-
//hookAdder.start();
620-
System.out.println("started");
621-
Thread.sleep(200);
622-
client.getStringValue("d", "a");
623-
client.addHooks(new Hook() {});
624-
client.getStringValue("d", "a");
625-
//latch.countDown();
626-
eval.join();
627-
hookAdder.join();
628-
System.out.println(concurrentModException.get());*/
629-
}
630-
}
631-
System.out.println("i = " + i);
632-
System.out.println("jaVar = " + jaVar);
633-
System.out.println("c.get() = " + c.get());
634-
}
635518
}

src/test/java/dev/openfeature/sdk/OpenFeatureClientTest.java

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,16 @@
22

33
import static org.assertj.core.api.Assertions.assertThat;
44
import static org.junit.jupiter.api.Assertions.assertEquals;
5-
import static org.junit.jupiter.api.Assertions.assertNotNull;
6-
import static org.junit.jupiter.api.Assertions.assertNull;
75
import static org.junit.jupiter.api.Assertions.assertThrows;
86
import static org.mockito.ArgumentMatchers.any;
97
import static org.mockito.ArgumentMatchers.anyString;
108
import static org.mockito.Mockito.mock;
119
import static org.mockito.Mockito.never;
1210

13-
import com.vmlens.api.AllInterleavings;
1411
import dev.openfeature.sdk.exceptions.FatalError;
1512
import dev.openfeature.sdk.fixtures.HookFixtures;
16-
import dev.openfeature.sdk.providers.memory.Flag;
17-
import dev.openfeature.sdk.providers.memory.InMemoryProvider;
1813
import dev.openfeature.sdk.testutils.TestEventsProvider;
19-
import java.util.ConcurrentModificationException;
2014
import java.util.HashMap;
21-
import java.util.concurrent.CountDownLatch;
22-
import java.util.concurrent.atomic.AtomicBoolean;
23-
import java.util.concurrent.atomic.AtomicReference;
2415
import org.junit.jupiter.api.AfterEach;
2516
import org.junit.jupiter.api.BeforeEach;
2617
import org.junit.jupiter.api.DisplayName;
@@ -113,64 +104,4 @@ void shouldNotCallEvaluationMethodsWhenProviderIsInNotReadyState() {
113104

114105
assertThat(details.getErrorCode()).isEqualTo(ErrorCode.PROVIDER_NOT_READY);
115106
}
116-
117-
//@Test
118-
void a() throws InterruptedException {
119-
OpenFeatureAPI api = new OpenFeatureAPI();
120-
121-
var flags = new HashMap<String, Flag<?>>();
122-
flags.put("a", Flag.builder().variant("a", "def").defaultVariant("a").build());
123-
flags.put("b", Flag.builder().variant("a", "as").defaultVariant("a").build());
124-
flags.put("c", Flag.builder().variant("a", "dfs").defaultVariant("a").build());
125-
flags.put("d", Flag.builder().variant("a", "asddd").defaultVariant("a").build());
126-
api.setProviderAndWait(new InMemoryProvider(flags));
127-
128-
var countDownLatch = new CountDownLatch(1);
129-
var client = new OpenFeatureClient(api, "name", "version");
130-
var isRunning = new AtomicBoolean(true);
131-
var eval = new Thread(() -> {
132-
try {
133-
countDownLatch.await();
134-
} catch (InterruptedException e) {
135-
throw new RuntimeException(e);
136-
}
137-
System.out.println("starting eval");
138-
while (isRunning.get()) {
139-
client.getStringValue("a", "def");
140-
client.getStringValue("b", "def");
141-
client.getStringValue("c", "def");
142-
client.getStringValue("d", "def");
143-
}
144-
});
145-
var hook = new Thread(() -> {
146-
try {
147-
countDownLatch.await();
148-
Thread.sleep(5);
149-
} catch (InterruptedException e) {
150-
throw new RuntimeException(e);
151-
}
152-
System.out.println("starting hook");
153-
while (isRunning.get()) {
154-
for (int i = 0; i < 100; i++) {
155-
156-
client.addHooks(new Hook() {});
157-
}
158-
159-
for (int i = 0; i < 90; i++) {
160-
161-
client.getHooks().remove(4);
162-
}
163-
}
164-
});
165-
166-
eval.start();
167-
hook.start();
168-
Thread.sleep(100);
169-
countDownLatch.countDown();
170-
Thread.sleep(40000);
171-
isRunning.set(false);
172-
eval.join();
173-
hook.join();
174-
System.out.println(client.getHooks().size());
175-
}
176107
}

0 commit comments

Comments
 (0)