question-mark
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.

Context::sessionAttribute(String) can return null value if attribute is not set but is typed as 'T' instead of 'T?'

See original GitHub issue

Actual behavior (the bug) Getting an attribute with Context::sessionAttribute(String) (which returns null if the attribute isn’t set) returns a T instead of T?.

This forces Kotlin users to add @Suppress("SENSELESS_COMPARISON") when checking if an attribute is null (or have an unexpected runtime NullPointerException).

Expected behavior sessionAttribute(String) should return T? instead of T.

Additional context Although an easy fix, this will “break” the API for Kotlin users that currently don’t have a null check when getting an attribute.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
FredDeschenescommented, Aug 28, 2018

Yeah I’ve been looking at all possible paths the setAttribute calls can take in Jetty’s source and turns out they don’t all have the same side effects when sending a null value: all of them will remove the attribute, except UpgradeHttpServletRequest which will just add the attribute with a null value -_-

I’ll go ahead and revert this back to what was already present except for the nullable stuff.

1reaction
tipsycommented, Aug 28, 2018

I see that other attribute functions have the same problem:

fun <T> attribute(attribute: String): T
fun <T> attributeMap(): Map<String, T>
fun <T> sessionAttribute(attribute: String): T
fun <T> sessionAttributeMap(): Map<String, T>

If you’d like to create a PR, please include all of them.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Informatica PowerExchange - Message Reference Volume 2
If not and the first run ID is the empty string use the APPCLEAR ... can return redo/undo data in the server's code...
Read more >
Developer Manual Third Edition Version 2.0.0 - MasterObjects
corresponding column is empty. ⇒ The ! character is the default value for constant. MdConstants.kMdFindEmptyString, and can thus be changed.
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 Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found