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

[Wisp] Fix initialization problem between JavaNetSocketAccess and its usage #443

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

zhengxiaolinX
Copy link
Contributor

Summary: JavaNetSocketAccess is used in WispServerSocketImpl.java, but the former one's initialization is in Socket.java. This underlying problem shall be fixed.

Test Plan: ServerSocketConnectionTest.java

Reviewed-by: D-D-H, yuleil

Issue: #437

@zhengxiaolinX zhengxiaolinX self-assigned this Nov 17, 2022
pb.start();
ss.accept();
} catch (Exception e) {
e.printStackTrace();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use Asserts.fail() for better readability

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

… usage

Summary: JavaNetSocketAccess is used in WispServerSocketImpl.java, but the former one's initialization is in Socket.java. This underlying problem shall be fixed.

Test Plan: ServerSocketConnectionTest.java

Reviewed-by: D-D-H, yuleil

Issue: #437


public class ServerSocketConnectionTest {

private static final String CLIENT = "SimpleClient";
private static final String PORT = "4039";
Copy link
Collaborator

Choose a reason for hiding this comment

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

IMHO, using a random port makes the test more stable.

Copy link
Collaborator

@D-D-H D-D-H Nov 21, 2022

Choose a reason for hiding this comment

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

use 0

port – the port number, or 0 to use a port number that is automatically allocated.

PORT // port
);
pb.start();
ss.accept();
Copy link
Collaborator

Choose a reason for hiding this comment

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

accept after started? is this intentional?

@@ -148,6 +149,7 @@ private static void initializeClasses() {
Class.forName(ShutdownEngine.class.getName());
Class.forName(AbstractShutdownTask.class.getName());
Class.forName(ShutdownControlGroup.class.getName());
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please add some comments to explain why we need this.

@@ -148,6 +149,7 @@ private static void initializeClasses() {
Class.forName(ShutdownEngine.class.getName());
Class.forName(AbstractShutdownTask.class.getName());
Class.forName(ShutdownControlGroup.class.getName());
Class.forName(Socket.class.getName());
Copy link
Collaborator

Choose a reason for hiding this comment

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

JavaNetSocketAccess is only used by ServerSocket, I suggest moving setJavaNetSocketAccess from Socket.<clinit> to ServerSocket.<clinit>. Thus, we don't need to preload Socket.class.

@CLAassistant
Copy link

CLAassistant commented Mar 31, 2023

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants