-
Notifications
You must be signed in to change notification settings - Fork 147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor stream handling for Cocoa and GTK in ImageLoader class #1760
Refactor stream handling for Cocoa and GTK in ImageLoader class #1760
Conversation
@HannesWell can you please review and merge this PR? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, using try-with-resources for these streams makes sense and the change looks sound.
But this also changes the behavior of the methods, as now an SWTError (ERROR_IO) will be thrown in case an IOException happens when closing the stream while currently that exception is swallowed.
I am still in favor of doing it, as it has already been changed that in Windows more than a year ago and (1) no one complained so far and (2) this change will make the implementations consistent across the operating systems again.
We might update the Javadoc as well to clarify that an error will also be thrown when closing the stream fails.
If closing fails we are probably all lost anyways... |
f1d84dd
to
995203f
Compare
I agree and updated the javadoc accordingly. |
bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/ImageLoader.java
Outdated
Show resolved
Hide resolved
I think we should not complicate this.... reading includes closing, and that a stream is used is and implementation detail, so simply say it do so when I/O error occurs when reading the file is enough. |
Agreed 👍 |
e470f1b
to
c00d202
Compare
Now it should be ready. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should not complicate this.... reading includes closing, and that a stream is used is and implementation detail, so simply say it do so when I/O error occurs when reading the file is enough.
Fully agree, even though Heiko is technically correct, this is a potential change in behavior, I think this is neglectable. In other clean-ups (from myself and others) in other parts of Eclipse the same simplification was already applied multiple times. So I also think this is fine.
bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/ImageLoader.java
Show resolved
Hide resolved
Refactor the file-stream handling by using try-with-resource for opening and closing them in `ImageLoader` for Cocoa and GTK (Windows already uses it).
c00d202
to
6776734
Compare
bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/ImageLoader.java
Show resolved
Hide resolved
The failure of browser-tests is unrelated and known, submitting. |
This PR refactors the stream handling by using try-with-resource for opening streams in the
ImageLoader
class for Cocoa and GTK.