-
Notifications
You must be signed in to change notification settings - Fork 334
Using Standard.AWS in Dual JVM mode
#14568
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
Merged
+70
−30
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
c74c534
Better to always provide factory to as_hideable_value
JaroslavTulach d89162f
Don't expose Java_File.new conversion in general API
JaroslavTulach f691d87
Using AWS in Dual JVM mode
JaroslavTulach eddb124
Always require factory=HideableValue
JaroslavTulach 03ea352
Note in changelog
JaroslavTulach 451aadc
Fixing missing import
JaroslavTulach 1b166ab
Copy File_Error.handle_java_exceptions to work in the right JVM
JaroslavTulach File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -2,13 +2,50 @@ private | |||
|
|
||||
| from Standard.Base import all | ||||
| import Standard.Base.Errors.File_Error.File_Error | ||||
| from Standard.Base.System.File import file_as_java | ||||
|
|
||||
| polyglot java import java.io.File as Java_File | ||||
| polyglot java import java.io.FileNotFoundException | ||||
| polyglot java import java.io.IOException | ||||
| polyglot java import java.io.UncheckedIOException | ||||
| polyglot java import java.nio.file.AccessDeniedException | ||||
| polyglot java import java.nio.file.DirectoryNotEmptyException | ||||
| polyglot java import java.nio.file.FileAlreadyExistsException | ||||
| polyglot java import java.nio.file.FileSystemException | ||||
| polyglot java import java.nio.file.NoSuchFileException | ||||
| polyglot java import java.nio.file.NotDirectoryException | ||||
| polyglot java import software.amazon.awssdk.core.sync.RequestBody | ||||
|
|
||||
| ## --- | ||||
| private: true | ||||
| --- | ||||
| from_local_file (file : File) = File_Error.handle_java_exceptions file <| | ||||
| java_file = file_as_java file | ||||
| RequestBody.fromFile java_file | ||||
| wrap_io_exception (file : File | Nothing) io_exception = | ||||
| associated_file = case io_exception of | ||||
| _ : FileSystemException -> | ||||
| path_from_exception = io_exception.getFile | ||||
| if path_from_exception.is_nothing then file else | ||||
| File.new path_from_exception | ||||
| _ -> file | ||||
|
|
||||
| ## If the file is not known, all we can do is throw a generic IO error. | ||||
| This will only usually matter on stream operations, where there is no relevant file - | ||||
| and so the exceptions like `NoSuchFileException` should not occur in such context. | ||||
| But instead of risking a Type_Error, we just throw the more generic IO_Error. | ||||
| if associated_file.is_nothing then Error.throw (File_Error.IO_Error Nothing "An IO error has occurred: "+io_exception.to_text) else case io_exception of | ||||
| _ : FileNotFoundException -> Error.throw (File_Error.Not_Found associated_file) | ||||
| _ : NoSuchFileException -> Error.throw (File_Error.Not_Found associated_file) | ||||
| _ : FileAlreadyExistsException -> Error.throw (File_Error.Already_Exists associated_file) | ||||
| _ : AccessDeniedException -> File_Error.access_denied associated_file | ||||
| _ : DirectoryNotEmptyException -> Error.throw (File_Error.Directory_Not_Empty associated_file) | ||||
| _ : NotDirectoryException -> Error.throw (File_Error.Not_A_Directory associated_file) | ||||
| _ -> Error.throw (File_Error.IO_Error associated_file "An IO error has occurred: "+io_exception.to_text) | ||||
|
|
||||
| handle_java_exceptions (file : File | Nothing) ~action = | ||||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Proper Fix
|
||||
| handle_io_exception caught_panic = | ||||
| wrap_io_exception file caught_panic.payload | ||||
| handle_unchecked_io_exception caught_panic = | ||||
| wrap_io_exception file caught_panic.payload.getCause | ||||
| Panic.catch IOException handler=handle_io_exception <| | ||||
| Panic.catch UncheckedIOException handler=handle_unchecked_io_exception <| | ||||
| action | ||||
|
|
||||
| from_local_file (file : File) = | ||||
| handle_java_exceptions file <| | ||||
| java_file = Java_File.new file.absolute.normalize.path | ||||
| RequestBody.fromFile java_file | ||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.