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.

Move LwM2mVersion in DefaultRegistrationEngine as a field instead of local variable

See original GitHub issue

I’m migrating LwM2m 1.0 test client to LwM2m 1.1 but I want to keep also the possibility the client to register as a 1.0 device. I’m using a command line parameter which switches the client to support LwM2m 1.0 or 1.1 but when the client registers to the server it always does this as a 1.1 device. I found that this is happening because in the DefaultRegistrationEngine class the LwM2mVersion is used as a local variable in the private Status register(ServerIdentity server) throws InterruptedException method and it’s always set to the latest supported version.

Is it possible to move the LwM2mVersion as a field which always keeps the latest supported LwM2m version instead of local variable? In this case if someone wants to use Leshan 2.0 libraries but to register a client which support older LwM2m version, he/she can use a ‘setter’ telling the version his/her client wants to use. This will give the possibility to tests some backward compatibility migrating a LwM2m server to support 1.1 but using the same Leshan client libraries.

I can propose this change in a pull request, but currently I don’t have permissions to do that.

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
sbernard31commented, Apr 21, 2022

I’m migrating LwM2m 1.0 test client to LwM2m 1.1 but I want to keep also the possibility the client to register as a 1.0 device.

I totally understand that this could be a user request.

At first sight this looks like a simple modification, just using 1.0 or 1.1 value for LWM2M version. But there is more behavior changes than this and so providing a client which is able to behave as a LWM2M v1.0 or a LWM2M v1.1 client is not that easy…

For now we made the choice to just target LWM2M v1.1 for Leshan v2.x. So, if you really want to test LWM2M v1.0 client you should keep using Leshan v1.x. And using Leshan v2.x when you want to test with a LWM2M v1.1 client.

Is it possible to move the LwM2mVersion as a field which always keeps the latest supported LwM2m version instead of local variable?

I can consider this little change but I’m afraid that this bring you (or others) to the wrong way.

In this case if someone wants to use Leshan 2.0 libraries but to register a client which support older LwM2m version, he/she can use a ‘setter’ telling the version his/her client wants to use. This will give the possibility to tests some backward compatibility migrating a LwM2m server to support 1.1 but using the same Leshan client libraries.

The wrong way because you will not really test backward compatibility, you will just test what happens when a client says it is a LWM2M v1.0 one but behave like a LWM2M v1.1 client…


So let’s talk about this, does it sound OK to you to use Leshan v1.x for LWM2M v1.0 and Leshan v2.x for LWM2M v1.1 ? If not, could you explain what you consider as a a problem with this way ? (maybe we will find a solution) 🙏

0reactions
sbernard31commented, Jun 3, 2022

I close this one but feel free to reopen or comment if needed. (Note that I let #1244 open)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Choose LWM2M version for Leshan Client #1244 - GitHub
Choose LWM2M version for Leshan Client #1244 ... Move LwM2mVersion in DefaultRegistrationEngine as a field instead of local variable #1241.
Read more >
Field can be converted to a local variable - Stack Overflow
"Field can be converted to a local variable" message appearing when setting Android ActionBar colour. Save this question. Show activity on this post....
Read more >
Code Inspection: Private field can be converted to local variable
First, this transformation will normally reduce memory usage (however, this effect may be minimized by JIT optimization).
Read more >
Local Variables - NI - National Instruments
To associate a local variable with a control or indicator, right-click the local variable node and select Select Item from the shortcut menu....
Read more >
Private fields only used as local variables in methods should ...
When the value of a private field is always assigned to in a class' methods before being read, then it is not being...
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