Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Java and Kotlin lambdas break the parser

See original GitHub issue

Hey, it’s me again 👋

I’m having an issue which breaks the code generator similarly to

This time it’s happening with Java and Kotlin lambdas. Examples:

!{var name = java.util.Optional.<String>ofNullable(null)}
${ -> { "name: " + n }).orElse("")}

Which produces:

public static void render(gg.jte.TemplateOutput jteOutput, gg.jte.html.HtmlInterceptor jteHtmlInterceptor) {
	var name = java.util.Optional.<String>ofNullable(null);
	jteOutput.writeUserContent( -> { "name: " + n );

While this:

!{val name: String = null}
${name?.let { "name: $it" } ?: ""}


@JvmStatic fun render(jteOutput:gg.jte.TemplateOutput, jteHtmlInterceptor:gg.jte.html.HtmlInterceptor?) {
	val name: String? = null
	jteOutput.writeUserContent(name?.let { "name: $it" )
	jteOutput.writeContent(" ?: \"\"}\n")

Looks like the parser is accepting the first } character as closing the ${} block.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

edrd-fcommented, Sep 3, 2021


casidcommented, Aug 30, 2021

Ahh, right. Forgot you’re generating Kotlin code. In this case you’re using ContentType.Plain anyways and there’s no output escaping. Thanks for clarifying!

I’ll try to release a new version this weekend.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Break out of lambda in kotlin - Stack Overflow
I am trying to add an very useful extension method to Java's InputStream class, since we know stream parsing requires several ...
Read more >
Cant break out of lambda - Native - Kotlin Discussions
Hi Team, I am trying to add an very useful extension method to Java's InputStream class, since we know stream parsing requires several...
Read more >
A complete guide to Kotlin lambda expressions
In this post, we'll dive into Kotlin's lambdas. We'll explore what they are, how they are structured, and where they can be used....
Read more >
From zero to 10 million lines of Kotlin - Engineering at Meta
We're sharing lessons learned from shifting from Java to Kotlin. ... Although Java 8 adds support for lambdas and is available for Android, ......
Read more >
Reading from the Command-Line in Kotlin - Sean Soper
We're going to call it the very originally named CommandLineParser . By bundling all of our parsing functionality into a single file we...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found