Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public final class OutputStrategyExt {

Expand Down Expand Up @@ -101,10 +102,12 @@ public RubyClass classFor(final ThreadContext context, final IRubyObject type) {
if (!klass.isTrue()) {
throw new IllegalArgumentException(
String.format(
"Could not find output delegator strategy of type '%s'. Value strategies: %s",
type.asJavaString(),
map.values(context).stream().map(v -> ((IRubyObject) v).asJavaString())
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IRubyObject#asJavaString has a base implementation in RubyBasicObject that throws a type-error unless the IRubyObject is string-like (e.g., trivially coercible to a string), so it doesn't work well with the RubyClass instances that are values in the map.

.collect(Collectors.joining(", "))
"Could not find output delegator strategy of type '%s'. Supported strategies: %s",
type.inspect().asJavaString(),
((Stream<IRubyObject>)map.keys(context).stream())
.map(IRubyObject::inspect)
.map(IRubyObject::asString)
.collect(Collectors.joining(", "))
)
);
}
Expand Down
Loading