If you do not call shutdownNow when the transfer is completed in the Java SDK of AWS S3, threads will continue to remain

https://docs.aws.amazon.com/ja_jp/AmazonS3/latest/dev/HLuploadFileJava.html Describes how to upload files to S3.

However, if you do not call shutdownNow at the end of the process here, it seems that s3Client threads may continue to remain. (Maybe it depends on the SDK version.)

        AmazonS3 s3Client = AmazonS3ClientBuilder.standard()
                .withRegion(clientRegion)
                .withCredentials(new ProfileCredentialsProvider())
                .build();
        TransferManager tm = TransferManagerBuilder.standard()
                .withS3Client(s3Client)
                .build();

        // TransferManager processes all transfers asynchronously,
        // so this call returns immediately.
        Upload upload = tm.upload(bucketName, keyName, new File(filePath));
        System.out.println("Object upload started");

        // Optionally, wait for the upload to finish before continuing.
        upload.waitForCompletion();
        System.out.println("Object upload complete");

// You need to close the transfer manager as follows. tm.shutdownNow();

reference

https://www.tcmobile.jp/dev_blog/programming/%E3%80%90java%E3%80%91cse%E3%83%9E%E3%83%AB%E3%83%81%E3%83%91%E3%83%BC%E3%83%88%E3%82%A2%E3%83%83%E3%83%97%E3%83%AD%E3%83%BC%E3%83%89%E3%82%92%E5%88%A9%E7%94%A8%E3%81%97%E3%80%81s3%E3%81%B8/

Recommended Posts

If you do not call shutdownNow when the transfer is completed in the Java SDK of AWS S3, threads will continue to remain
What to do if Operation not permitted is displayed when you execute a command in the terminal
[Note] What to do if bundle install in Chapter 3 of the rails tutorial is not possible
What to do if the prefix c is not bound in JSP
[RSpec] When you want to use the instance variable of the controller in the test [assigns is not recommended]
What to do if you can't get the text of an element in Selenium
[Maven] What to do if you are asked to incorporate a jar that is not in the remote repository into the war
[Swift] When you want to know if the number of characters in a String matches a certain number ...
What to do when "relation" hibernate_sequence "does not exist" in the ID column of PostgreSQL + JPA
What to do when you want to know the source position where the method is defined in binding.pry
Static function to check if the RGB error of BufferdImage is within the specified ratio in Java
What to do if the app is not created with the latest Rails version installed when rails new
[Ubuntu 20.04] What to do if the external monitor is not recognized
[Rails] What to do if data is not registered in DB
What to do when the changes in the Servlet are not reflected
What to do if Cloud9 is full in the Rails tutorial
The milliseconds to set in /lib/calendars.properties of Java jre is UTC
What to do if you forget the root password in CentOS7
The first thing to do when you want to be happy with Heroku on GitHub with Eclipse in Java
When will you do the refactoring?
[Rails] What to do if you get an error saying "Could not find a JavaScript runtime." When executing the rails s command on Catalina
What to do if the background image is not applied after deployment
How to find the total number of pages when paging in Java
How to constrain the action of the transition destination when not logged in
What to do if tomcat process remains when tomcat is stopped in eclipse
[Rails] What to do when the Refile image is not displayed when writing the processing at the time of Routing Error
What to do if you get an "A server is already running." Error when you try to start the rails server
What to do when you think you can't do Groovy-> Java in IntelliJ IDEA CE
If you want to satisfy the test coverage of private methods in JUnit
What to do if the changes are not reflected in the jar manifest file
What to do when rails db: seed does not reflect in the database
[Java] Why do you bother to use the interface (Spring is also available)
Until you run a Java program with the AWS SDK local to Windows
[Swift] What to do if the app icon is set but not reflected
[Java] Is it unnecessary to check "identity" in the implementation of the equals () method?
Code that deletes all files of the specified prefix in AWS S3 (Java)
How to set when "The constructor Empty () is not visible" occurs in junit
Is it mainstream not to write the closing tag of <P> tag in Javadoc?
Cause of is not visible when calling a method of another class in java
What to do if you hit the wall of Too many symbol files when uploading with App Store Connect
What to do when ‘Could not find’ in any of the sources appears in the development environment with Docker × Rails × RSpec
[Java] When putting a character string in the case of a switch statement, it is necessary to make it a constant expression
Even if I want to convert the contents of a data object to JSON in Java, there is a circular reference ...
[Java] What to do if the contents saved in the DB and the name of the enum are different in the enum that reflects the DB definition
What to do if you get the warning "Uniqueness validator will no longer enforce case sensitive comparison in Rails 6.1." in Rails 6.0