Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JDK-8282354 : Remove dependancy of TestHttpServer, HttpTransaction, HttpCallback from open/test/jdk/ tests #7616

Closed
wants to merge 11 commits into from

Conversation

mahendrachhipa
Copy link
Member

@mahendrachhipa mahendrachhipa commented Feb 24, 2022

Updated following remaining tests to remove depenedies of TestHttpServer, HttpTransaction, HttpCallback
open/test/jdk/java/net/ProxySelector/LoopbackAddresses.java
open/test/jdk/java/net/ProxySelector/ProxyTest.java
open/test/jdk/java/net/URL/PerConnectionProxy.java
open/test/jdk/java/net/URLConnection/B5052093.java
open/test/jdk/sun/net/www/AuthHeaderTest.java
open/test/jdk/sun/net/www/http/KeepAliveCache/B5045306.java


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8282354: Remove dependancy of TestHttpServer, HttpTransaction, HttpCallback from open/test/jdk/ tests

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/7616/head:pull/7616
$ git checkout pull/7616

Update a local copy of the PR:
$ git checkout pull/7616
$ git pull https://git.openjdk.java.net/jdk pull/7616/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 7616

View PR using the GUI difftool:
$ git pr show -t 7616

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/7616.diff

Sorry, something went wrong.

@bridgekeeper
Copy link

bridgekeeper bot commented Feb 24, 2022

👋 Welcome back mahendrachhipa! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr Pull request is ready for review label Feb 24, 2022
@openjdk
Copy link

openjdk bot commented Feb 24, 2022

@mahendrachhipa The following label will be automatically applied to this pull request:

  • net

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the net net-dev@openjdk.org label Feb 24, 2022
@mlbridge
Copy link

mlbridge bot commented Feb 24, 2022

Webrevs

server = new TestHttpServer (new LoopbackAddresses(), 1, 10, 0);
ProxyServer pserver = new ProxyServer(InetAddress.getByName("localhost"), server.getLocalPort());
server = HttpServer.create(new InetSocketAddress(loopback, 0), 10);
server.createContext("/", new LoopbackAddresses());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While here, we could use the new HttpServer::create overload that creates a server with a context (applies to all tests touched.)

I also wonder if it would make sense to change the names of the classes that implement HttpHandler to "xyzHandler" for readability, and to create a separate class for the handler instead of using the test class.

@openjdk openjdk bot removed the rfr Pull request is ready for review label Feb 25, 2022
@openjdk openjdk bot added the rfr Pull request is ready for review label Feb 25, 2022
Comment on lines 166 to 168
try(PrintWriter pw = new PrintWriter(exchange.getResponseBody())) {
pw.print("Hello .");
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know that now UTF-8 is supposed to be the default - but I'd prefer to either make it explicit, or add a comment stating that since Java 18 PrintWriter will use UTF-8 encoding by default.

} catch (IOException e) {
e.printStackTrace();
}
try(PrintWriter pw = new PrintWriter(exchange.getResponseBody())) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same remark here

exchange.sendResponseHeaders(200, 0);
} catch (IOException e) {
}
try(PrintWriter pw = new PrintWriter(exchange.getResponseBody())) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here too

Comment on lines +108 to +113
try {
exchange.getResponseHeaders().set("content-length", Long.toString(B5052093.testSize));
exchange.sendResponseHeaders(200, 0);
exchange.close();
} catch (IOException e) {
e.printStackTrace();
Copy link
Member

@dfuch dfuch Mar 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure that this results in the same response headers than before?
If I'm not mistaken here we will send both Content-Length and Transfer-Encoding: chunked. Was that what the previous server did, and what the test wants to test?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, previously also, setting the content-length Integer.MAX_VALUE)) + 2, and was not sending any content. Here wanted to test, that URLConnection.getContentLength() does not throw NumberFormatException and return -1 if content-length is long value.
In case of HttpExchange.setResponseHeader(). If responseLength is -1, then content-length value is overridden to 0, if already set explicitly. Same is the case when responseLength is > 0. Only in the case when responseLength == 0, content-length value is not overriden if already set explicitly., thats why I am using chunked encoding and not writing any data.

}
if (!uncaught.isEmpty()) {
throw new RuntimeException("Unhandled exception:", uncaught.get(0));
}
}
}

class SimpleHttpTransaction implements HttpCallback
class SimpleHttpTransactionHandler implements HttpHandler
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the boolean failed should at least be volatile

trans.setResponseEntityBody (responseBody, responseBody.length);
trans.sendResponse(200, "OK");
trans.sendResponseHeaders(200, 0);
try(PrintWriter pw = new PrintWriter(trans.getResponseBody())) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same remark about UTF-8 here again


void okReply (HttpExchange req) throws IOException {
req.sendResponseHeaders (200, 0);
try(PrintWriter pw = new PrintWriter(req.getResponseBody())) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same remark about UTF-8

e.printStackTrace();
}
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing newline at end of file?

Comment on lines 205 to 206
trans.getResponseHeaders().set("Content-length", Integer.toString(responseBody.length+1));
trans.sendResponseHeaders(200, 0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here again we will be mixing Content-Length and chunked

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case of HttpExchange.setResponseHeader(). If responseLength is -1, then content-length value is overridden to 0, if already set explicitly. Same is the case when responseLength is > 0. Only in the case when responseLength == 0, content-length value is not overriden if already set explicitly., that's why I am using chunked encoding and writing the data less than the content length.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand why you do it - but the client will react differently if both Content-Length and chunk are specified, as opposed to when only Content-Length is specified. So I just want to make sure that we are testing the same thing than before. If we are not testing the same thing, then you might have to use a ServerSocket directly - rather than an HttpServer, to make sure we're sending back the same things than before.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now not using Transfer-Encoding Chunk.


trans.getResponseHeaders().set("Content-length", Integer.toString(responseBody.length+1));
trans.sendResponseHeaders(200, 0);
try(PrintWriter pw = new PrintWriter(trans.getResponseBody())) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same remark for UTF-8

@openjdk openjdk bot removed the rfr Pull request is ready for review label Mar 4, 2022
@openjdk openjdk bot added the rfr Pull request is ready for review label Mar 4, 2022
Copy link
Member

@dfuch dfuch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@openjdk
Copy link

openjdk bot commented Mar 10, 2022

@mahendrachhipa This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8282354: Remove dependancy of TestHttpServer, HttpTransaction, HttpCallback from open/test/jdk/ tests

Reviewed-by: dfuchs

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 61 new commits pushed to the master branch:

  • 2674799: 8282878: Removed _JavaThread from PhaseTraceTime
  • 7c8ea9f: 8282509: [exploded image] ResolvedClassTest fails with similar output
  • 9c88c5b: 8282948: JDK-8274980 missed correct handling of MACOSX_BUNDLE_BUILD_VERSION
  • 83d7718: 8282893: Remove MacroAssembler::push/pop_callee_saved_registers
  • 6a3a7b9: 6218162: DefaultTableColumnModel.getColumn() method should mention ArrayIndexOutOfBoundsException
  • 5b78a82: 7017094: ParsedSynthStyle: parameter name "direction" should be changed to "tabIndex"
  • 8aba4de: 8249592: Robot.mouseMove moves cursor to incorrect location when display scale varies and Java runs in DPI Unaware mode
  • ff76620: 8282641: Make jdb "threadgroup" command with no args reset the current threadgroup back to the default
  • 70318e1: 8282884: Provide OID aliases for MD2, MD5, and OAEP
  • 6d8d156: 8280494: (D)TLS signature schemes
  • ... and 51 more: https://git.openjdk.java.net/jdk/compare/b3837808bf13de2aa3d8c6c21cf61baac9baf2b2...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@dfuch) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Mar 10, 2022
@mahendrachhipa
Copy link
Member Author

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Mar 10, 2022
@openjdk
Copy link

openjdk bot commented Mar 10, 2022

@mahendrachhipa
Your change (at version 7f94771) is now ready to be sponsored by a Committer.

@dfuch
Copy link
Member

dfuch commented Mar 11, 2022

/sponsor

@openjdk
Copy link

openjdk bot commented Mar 11, 2022

Going to push as commit 95ca944.
Since your change was applied there have been 75 commits pushed to the master branch:

  • f99193a: 8282811: Typo in IAE details message of RecordedObject.getValueDescriptor
  • cab9def: 8282700: Properly handle several --without options during configure
  • 1a5a496: 8282763: G1: G1CardSetContainer remove intrusive-list details.
  • 88f0938: 8272493: Suboptimal code generation around Preconditions.checkIndex intrinsic with AVX2
  • a5a1a32: 8282883: Use JVM_LEAF to avoid ThreadStateTransition for some simple JVM entries
  • bb7ee5a: 8282314: nsk/jvmti/SuspendThread/suspendthrd003 may leak memory
  • f5217b4: 8282852: Debug agent asserts in classTrack_addPreparedClass()
  • 7b91bbb: 8282170: JVMTI SetBreakpoint metaspace allocation test
  • b13cacc: 8254574: PrintWriter handling of InterruptedIOException should be removed
  • 1f29523: 8282932: a space is needed for the unsupported protocol exception message in ProtocolVersion
  • ... and 65 more: https://git.openjdk.java.net/jdk/compare/b3837808bf13de2aa3d8c6c21cf61baac9baf2b2...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Mar 11, 2022
@openjdk openjdk bot closed this Mar 11, 2022
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review sponsor Pull request is ready to be sponsored labels Mar 11, 2022
@openjdk
Copy link

openjdk bot commented Mar 11, 2022

@dfuch @mahendrachhipa Pushed as commit 95ca944.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integrated Pull request has been integrated net net-dev@openjdk.org
Development

Successfully merging this pull request may close these issues.

3 participants