Skip to content

Use SerialPort with try-with-resources#384

Open
findepi wants to merge 1 commit into
Fazecast:masterfrom
findepi:findepi/use-serialport-with-try-with-resources-2902a7
Open

Use SerialPort with try-with-resources#384
findepi wants to merge 1 commit into
Fazecast:masterfrom
findepi:findepi/use-serialport-with-try-with-resources-2902a7

Conversation

@findepi

@findepi findepi commented Dec 31, 2021

Copy link
Copy Markdown

Let the SerialPort implement AutoCloseable. This requires bumping
minimal required Java version to 7.

Let the `SerialPort` implement `AutoCloseable`. This requires bumping
minimal required Java version to 7.
@findepi

findepi commented Dec 31, 2021

Copy link
Copy Markdown
Author

This requires bumping
minimal required Java version to 7.

of course, i've no idea whether this is an OK change for the project.

@hedgecrw

Copy link
Copy Markdown
Contributor

Thanks for the PR. This is a great idea; however, it's not feasible at the moment as we need to maintain Java 6 compatibility. As soon as global Java 6 usage decreases down to less than 1% (looks like it's currently at around 6%), we can consider bumping the version and adding this. I will leave this PR open until that time.

@hedgecrw

Copy link
Copy Markdown
Contributor

The next major release (3.X.X series) will drop support for Java 6. Support for try-with-resources will be added at that time.

@tugalsan

tugalsan commented Apr 3, 2023

Copy link
Copy Markdown

I watched some Venkat Subramaniam videos.

He says rather than using try-with-resources, it is better to use a function with lamda in it. like: ClassName.use(something-> ...)

Beause many forget to use try as there is no compile time check for autoclosable.

@tugalsan

tugalsan commented Apr 7, 2023

Copy link
Copy Markdown

I wrote an exmaple here to show u the 'use' case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants