RFR: 8255584: `HttpPrincipal::getName` returns incorrect name

Daniel Fuchs dfuchs at openjdk.java.net
Fri Oct 30 15:31:55 UTC 2020


On Fri, 30 Oct 2020 14:41:18 GMT, Patrick Concannon <pconcannon at openjdk.org> wrote:

> Hi,
> 
> Could someone please review my fix for JDK-8255584: '`HttpPrincipal::getName` returns incorrect name' ?
> The specification for `HttpPrincipal::getName` reports that it should return the name of the HttpPrincipal in the format "realm:username". However, it currently returns the username only.
> 
> This fix updates the method to return the name in the correct format as specified by the javadoc. 
> 
> Kind regards,
> Patrick

src/jdk.httpserver/share/classes/com/sun/net/httpserver/HttpPrincipal.java line 78:

> 76:      */
> 77:     public String getName() {
> 78:         return String.format("%s:%s", username, realm);

Isn't it the opposite you should do Patrick :-) ?
:username```

test/jdk/com/sun/net/httpserver/HttpPrincipalTest.java line 44:

> 42:         assertEquals(principal.getUsername(), "test");
> 43:         assertEquals(principal.getRealm(), "123");
> 44:         assertEquals(principal.getName(), "test:123");

should be "123:test" here.

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

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


More information about the net-dev mailing list