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

Exception infomation lost when some Exception occurs

Open terrason opened this issue 2 years ago • 3 comments

图片 I meet an OOM Exception ,but it's hard to find out . The exception caught outside just says: java.lang.RuntimeException: null

Caused by: java.lang.RuntimeException: null
	at io.minio.S3Base.throwEncapsulatedException(S3Base.java:243)
	at io.minio.MinioClient.putObject(MinioClient.java:1375)
        ....

I personally strongly advise to fix this by changing io.minio.S3Base.java:243 with :

- throw new RuntimeException(exc.getCause());
+ throw new RuntimeException("Failed to put object:" + ext.getMessage(), exc);

The error message may be something better. https://github.com/minio/minio-java/blob/8c7a5be3a42ae0e1f4da9269e97a30729b3cbf83/api/src/main/java/io/minio/S3Base.java#L243

terrason avatar Dec 29 '22 05:12 terrason

Feel free to send a PR

balamurugana avatar Dec 29 '22 06:12 balamurugana

Unfortunately, only the ExecutionException passed into throwEncapsulatedException has the stack trace from the call site. The cause in it doesn't have a meaningful stack trace since it comes from a different thread. The only way to keep the stack trace would be to keep ExecutionException, but doing so would make pretty much all checked exception annotations on API functions invalid and make it harder to check the type of exception.

A solution is to just avoid the broken synchronous MinioClient wrapper and use MinioAsyncClient directly; at the cost of having to call .get() yourself and having to check exception causes yourself.

minus7 avatar Feb 20 '23 15:02 minus7

A header you provided implies functionality that is not implemented? anyone met this problem when use the .startAfter() for querying objects

geniusxc avatar Apr 21 '23 10:04 geniusxc