Skip to content

Commit 7d84c2d

Browse files
committed
[GR-10706] Fixed merge issues.
1 parent 6880428 commit 7d84c2d

File tree

2 files changed

+35
-13
lines changed
  • truffle/src

2 files changed

+35
-13
lines changed

truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/polyglot/LoggingTest.java

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -449,12 +449,7 @@ public void testGcedContext() {
449449
Assert.assertEquals(expected, handler.getLog());
450450
Reference<Context> gcedContextRef = new WeakReference<>(gcedContext);
451451
gcedContext = null;
452-
for (int i = 1; gcedContextRef.get() != null; i++) {
453-
if (i == 10) {
454-
throw new AssertionError("Cannot free context.");
455-
}
456-
System.gc();
457-
}
452+
assertGc("Cannot free context.", gcedContextRef);
458453
handler = new TestHandler();
459454
Context newContext = Context.newBuilder().logHandler(handler).build();
460455
newContext.eval(LoggingLanguageFirst.ID, "");
@@ -479,12 +474,7 @@ public void testGcedContext2() {
479474
Assert.assertEquals(expected, contextHandler.getLog());
480475
Reference<Context> gcedContextRef = new WeakReference<>(gcedContext);
481476
gcedContext = null;
482-
for (int i = 1; gcedContextRef.get() != null; i++) {
483-
if (i == 10) {
484-
throw new AssertionError("Cannot free context.");
485-
}
486-
System.gc();
487-
}
477+
assertGc("Cannot free context.", gcedContextRef);
488478
contextHandler.clear();
489479
context.eval(LoggingLanguageFirst.ID, "");
490480
expected = new ArrayList<>();
@@ -614,6 +604,38 @@ private static LoggerNode createLevelsTree(Map<String, Level> levels) {
614604
return root;
615605
}
616606

607+
private static void assertGc(final String message, final Reference<?> ref) {
608+
int blockSize = 100_000;
609+
final List<byte[]> blocks = new ArrayList<>();
610+
for (int i = 0; i < 50; i++) {
611+
if (ref.get() == null) {
612+
return;
613+
}
614+
try {
615+
System.gc();
616+
} catch (OutOfMemoryError oom) {
617+
}
618+
try {
619+
System.runFinalization();
620+
} catch (OutOfMemoryError oom) {
621+
}
622+
try {
623+
blocks.add(new byte[blockSize]);
624+
blockSize = (int) (blockSize * 1.3);
625+
} catch (OutOfMemoryError oom) {
626+
blockSize >>>= 1;
627+
}
628+
if (i % 10 == 0) {
629+
try {
630+
Thread.sleep(500);
631+
} catch (InterruptedException ie) {
632+
break;
633+
}
634+
}
635+
}
636+
Assert.fail(message);
637+
}
638+
617639
public static final class LoggingContext {
618640
private final TruffleLanguage.Env env;
619641

truffle/src/com.oracle.truffle.api.vm/src/com/oracle/truffle/api/vm/PolyglotImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -961,7 +961,7 @@ public Map<String, Level> getLogLevels(final Object context) {
961961
if (!(context instanceof PolyglotContextImpl)) {
962962
throw new AssertionError();
963963
}
964-
return ((PolyglotContextImpl) context).logLevels;
964+
return ((PolyglotContextImpl) context).config.logLevels;
965965
}
966966
}
967967
}

0 commit comments

Comments
 (0)