Skip to content

Commit

Permalink
Fixed flaky test in DisposableSupplierText.java with set comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
mumbler6 authored Oct 22, 2024
1 parent ff5f5a8 commit c2e1271
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2024 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand All @@ -17,6 +17,8 @@
package org.glassfish.jersey.inject.cdi.se;

import java.lang.reflect.Type;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Supplier;
Expand Down Expand Up @@ -368,9 +370,17 @@ public void testDisposeComposedObjectWithPerLookupFields() {

// All instances should be the same because they are request scoped.
ComposedObject instance = injectionManager.getInstance(ComposedObject.class);
assertEquals("1", instance.getFirst());
assertEquals("2", instance.getSecond());
assertEquals("3", instance.getThird());
Set<String> set1 = new HashSet<String>() {{
add("1");
add("2");
add("3");
}};
Set<String> set2 = new HashSet<String>() {{
add(instance.getFirst().toString());
add(instance.getSecond().toString());
add(instance.getThird().toString());
}};
assertEquals(set1, set2);
});

Supplier<String> cleanedSupplier = atomicSupplier.get();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2024 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand All @@ -17,6 +17,8 @@
package org.glassfish.jersey.inject.hk2;

import java.lang.reflect.Type;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Supplier;
Expand Down Expand Up @@ -374,9 +376,17 @@ public void testDisposeComposedObjectWithPerLookupFields() {

// All instances should be the same because they are request scoped.
ComposedObject instance = injectionManager.getInstance(ComposedObject.class);
assertEquals("1", instance.first);
assertEquals("2", instance.second);
assertEquals("3", instance.third);
Set<String> set1 = new HashSet<String>() {{
add("1");
add("2");
add("3");
}};
Set<String> set2 = new HashSet<String>() {{
add(instance.first.toString());
add(instance.second.toString());
add(instance.third.toString());
}};
assertEquals(set1, set2);
});

Supplier<String> cleanedSupplier = atomicSupplier.get();
Expand Down

0 comments on commit c2e1271

Please sign in to comment.