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.

Null cache exception in FlatMap

See original GitHub issue

I’m currently updating a project that was written under Binding.scala 10.0.3 (and compiled/ran fine) to 11.8.1. Updating the library caused a null error to surface that previously wasn’t there.

Specifically, in line 408 of Binding.scala, oldCache is null.

Looking through the changes to the relevant code since 10.0.03, I can see that this commit added a cache which is initialised to null.

Either there was some invariant that meant that oldCache should never be null (in which I need to fix my code) or a null check needs to be made.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
Atrycommented, Jul 20, 2019

Recursive code layout does not matter. What matters here is to avoid recursive Var changes.

Yang, Bo pop.atry@gmail.com于2019年7月20日 周六下午1:54写道:

The oninput handler and the Future block are functions other than the @dom function. You know, their return types are not Binding, and they will be not triggered by Var or Vars changes.

Basim Khajwal notifications@github.com于2019年7月20日 周六下午12:52写道:

Right, I understand.

One thing I’m still unsure about is the typical pattern for input elements which goes like:

import org.scalajs.dom.html

@dom def inputElement(data: Var[String]): Binding[html.Input] = { <input oninput={e:Event => data.value = e.target.asInstanceOf[html.Input].value} value={data.bind} /> }

This is still a recursive binding that works however it still invalidates the principle that value_= should never be called within a @dom expression.

Moving the oninput to an external function kind of resolves it but it still effectively does the same thing (recursive) so I’m still unsure as to how to properly handle this situation (if there is an alternative).

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/ThoughtWorksInc/Binding.scala/issues/188?email_source=notifications&email_token=AAES3OVAJZ5OVAKNDPTVZN3QANUG7A5CNFSM4IFM5H52YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2NU4DA#issuecomment-513494540, or mute the thread https://github.com/notifications/unsubscribe-auth/AAES3OU4GZSQYPHEIYTGY2DQANUG7ANCNFSM4IFM5H5Q .

– 杨博 (Yang, Bo)

– 杨博 (Yang, Bo)

0reactions
Atrycommented, Jul 20, 2019

The oninput handler and the Future block are functions other than the @dom function. You know, their return types are not Binding, and they will be not triggered by Var or Vars changes.

Basim Khajwal notifications@github.com于2019年7月20日 周六下午12:52写道:

Right, I understand.

One thing I’m still unsure about is the typical pattern for input elements which goes like:

import org.scalajs.dom.html

@dom def inputElement(data: Var[String]): Binding[html.Input] = { <input oninput={e:Event => data.value = e.target.asInstanceOf[html.Input].value} value={data.bind} /> }

This is still a recursive binding that works however it still invalidates the principle that value_= should never be called within a @dom expression.

Moving the oninput to an external function kind of resolves it but it still effectively does the same thing (recursive) so I’m still unsure as to how to properly handle this situation (if there is an alternative).

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/ThoughtWorksInc/Binding.scala/issues/188?email_source=notifications&email_token=AAES3OVAJZ5OVAKNDPTVZN3QANUG7A5CNFSM4IFM5H52YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2NU4DA#issuecomment-513494540, or mute the thread https://github.com/notifications/unsubscribe-auth/AAES3OU4GZSQYPHEIYTGY2DQANUG7ANCNFSM4IFM5H5Q .

– 杨博 (Yang, Bo)

Read more comments on GitHub >

github_iconTop Results From Across the Web

rx java - Handling null in RxJava2 - Stack Overflow
For instance, in my app I have an in-memory cache: @Nullable CacheItem findCacheItem(long id); CacheItem might not be present in cache, so method...
Read more >
2.x: Handling null values · Issue #4644 · ReactiveX/RxJava
So with this approach, I might get null in my stream which is totally valid situation, so it is handled properly on receiving...
Read more >
Flux (reactor-core 3.5.1)
Returns that value, or null if the Flux completes empty. In case the Flux errors, the original exception is thrown (wrapped in a...
Read more >
Handling Exceptions in Project Reactor - Baeldung
As required by the specification, Reactor throws a NullPointerException when a null value reaches the map function. Therefore, there's nothing ...
Read more >
Promise (Ratpack API (2.0.0-rc-1))
A promise is a representation of a value which will become available later. Methods such as map(Function) , flatMap(Function) , cache() etc.) allow...
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