From 21c633ad8c655fc1cf244d86b17e3397cf8f4049 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Mon, 26 Jul 2021 20:59:58 +0200 Subject: [PATCH] fix(java-shell): allow console.warn and console.info eea5cd667d9b40 broke the waterfall tests, because BSON uses console.warn() when applied to the java shell as no secure random number generator is available, and the change upgraded the resulting error from a silent unhandled promise rejection to a full exception. Solve this by adding warn and info to the java-shell console for parity with the shell-api code. --- .../src/main/kotlin/com/mongodb/mongosh/ConsoleLogSupport.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/java-shell/src/main/kotlin/com/mongodb/mongosh/ConsoleLogSupport.kt b/packages/java-shell/src/main/kotlin/com/mongodb/mongosh/ConsoleLogSupport.kt index 382f1ac777..b6eeb17ff9 100644 --- a/packages/java-shell/src/main/kotlin/com/mongodb/mongosh/ConsoleLogSupport.kt +++ b/packages/java-shell/src/main/kotlin/com/mongodb/mongosh/ConsoleLogSupport.kt @@ -14,7 +14,9 @@ internal class ConsoleLogSupport(context: MongoShellContext, converter: MongoShe @Suppress("JSPrimitiveTypeWrapperUsage") val console = context.eval("new Object()") console["log"] = print + console["warn"] = print console["error"] = print + console["info"] = print context.bindings["console"] = console } @@ -26,4 +28,4 @@ internal class ConsoleLogSupport(context: MongoShellContext, converter: MongoShe this.printedValues = null } } -} \ No newline at end of file +}