minio-java icon indicating copy to clipboard operation
minio-java copied to clipboard

minio client close()

Open gongxuanzhang opened this issue 2 years ago • 4 comments

i use official website example : https://min.io/docs/minio/linux/developers/java/quickstart.html. success upload file to minio. but my program not exit . i think it's not close but class MinioClient don't have function close(). what should i do .


public class FileUploader {
  public static void main(String[] args)
      throws IOException, NoSuchAlgorithmException, InvalidKeyException {
    try {
      // Create a minioClient with the MinIO server playground, its access key and secret key.
      MinioClient minioClient =
          MinioClient.builder()
              .endpoint("https://play.min.io")
              .credentials("Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG")
              .build();

      // Make 'asiatrip' bucket if not exist.
      boolean found =
          minioClient.bucketExists(BucketExistsArgs.builder().bucket("asiatrip").build());
      if (!found) {
        // Make a new bucket called 'asiatrip'.
        minioClient.makeBucket(MakeBucketArgs.builder().bucket("asiatrip").build());
      } else {
        System.out.println("Bucket 'asiatrip' already exists.");
      }

      // Upload '/home/user/Photos/asiaphotos.zip' as object name 'asiaphotos-2015.zip' to bucket
      // 'asiatrip'.
      minioClient.uploadObject(
          UploadObjectArgs.builder()
              .bucket("asiatrip")
              .object("asiaphotos-2015.zip")
              .filename("/home/user/Photos/asiaphotos.zip")
              .build());
      System.out.println(
          "'/home/user/Photos/asiaphotos.zip' is successfully uploaded as "
              + "object 'asiaphotos-2015.zip' to bucket 'asiatrip'.");
    } catch (MinioException e) {
      System.out.println("Error occurred: " + e);
      System.out.println("HTTP trace: " + e.httpTrace());
    }
  }
}

gongxuanzhang avatar Feb 27 '24 03:02 gongxuanzhang

This is default okhttp behavior. Configure your own okhttp pool manager.

balamurugana avatar Feb 27 '24 03:02 balamurugana

thank you very much

gongxuanzhang avatar Feb 27 '24 03:02 gongxuanzhang

This is default okhttp behavior. Configure your own okhttp pool manager. can you give me example code ?

nguyenhuudung111 avatar Jul 26 '24 09:07 nguyenhuudung111

okhttp watchdog hang program.my main function may exit after serval minutes.Since the programe can exit,Obviously minio back thread hold the okhttp thread that lead to not exit properly

robinhood-jim avatar Jan 07 '25 15:01 robinhood-jim