googleapis / googleapis/google-http-java-client

HttpResponse should implement Closeable

Đang mở
#740 1 bình luận 2 reaction 0 người được giao Xem trên GitHub
type: feature request
Ngôn ngữ chính
Java
Star
1.4k
Fork
473
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

Currently a `HttpResponse` needs to be disconnected to release resources and avoid leaks. This is fine but it can lead to easy mistakes as people new to the library don't realise this or forget.

If `HttpResponse` implemented the `java.io.Closeable` interface then I think there would be a number of benefits:
- Can use try-with-resources. :+1: :+1: :+1:
- More familiar to developers by implementing the standard interface and using standard method names.
- IDEs and static analysis tools may pick up resource leaks automatically without any extra configuration.

The main downside I can see is that we'd have to keep the `disconnect` method for backwards compatibility and this would mean there would be two interfaces for the same action. Is this a problem? I leave that decision up to you.

I would be happy to implement this if that would help things. It shouldn't be very much work at all. I'm opening this feature request issue in order to gauge if it would be a good idea to implement this or not.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.