Skip to content

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

Open
zhengxiaolinX wants to merge 1 commit into
masterfrom
wisp-socket-3
Open

[Wisp] Fix initialization problem between JavaNetSocketAccess and its usage#443
zhengxiaolinX wants to merge 1 commit into
masterfrom
wisp-socket-3

Conversation

@zhengxiaolinX
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

Class.forName(ShutdownEngine.class.getName());
Class.forName(AbstractShutdownTask.class.getName());
Class.forName(ShutdownControlGroup.class.getName());
Class.forName(Socket.class.getName());
Copy link
Copy Markdown
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
Copy Markdown

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.

4 participants