RFR: 8270903: sun.net.httpserver.HttpConnection: Improve toString

Chris Hegarty chegar at openjdk.java.net
Wed Aug 4 12:48:28 UTC 2021


On Wed, 4 Aug 2021 10:54:10 GMT, Daniel Fuchs <dfuchs at openjdk.org> wrote:

>> This is a minor change that updates `sun.net.httpserver.HttpConnection::toString` to never return null.
>> 
>> Testing: tier 1-3 all clear
>
> src/jdk.httpserver/share/classes/sun/net/httpserver/HttpConnection.java line 69:
> 
>> 67: 
>> 68:     public String toString() {
>> 69:         final var sb = new StringBuilder(HttpConnection.class.getSimpleName());
> 
> Why not simplify into `new StringBuilder(getClass().getSimpleName());` ?

Have a marginal preference for HttpConnection.class.getSimpleName(), since it is a constant, but don't object to getClass().

-------------

PR: https://git.openjdk.java.net/jdk/pull/4928


More information about the net-dev mailing list