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

Replace Socket, ServerSocket, and HttpServer usages in tests with mocksocket versions #22287

Merged
merged 8 commits into from
Jan 4, 2017

Conversation

Tim-Brooks
Copy link
Contributor

This is related to #22116. In order to remove SocketPermissions from core we need to isolate some code that can be given SocketPermissions. The mocksocket jar includes wrapped versions of Socket and SocketServer. This is one step towards migrating permissions out of core.

@Tim-Brooks
Copy link
Contributor Author

This is currently blocked from being merged on a release of the mocksocket project.

I should get to today or tomorrow.

Copy link
Contributor

@s1monw s1monw left a comment

Choose a reason for hiding this comment

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

this PR LGTM provided MockSocket is available publicially

Copy link
Member

@jasontedor jasontedor left a comment

Choose a reason for hiding this comment

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

I left one comment.

@@ -19,6 +19,7 @@

package org.elasticsearch.transport.netty4;

import org.elasticsearch.MockSocket;
Copy link
Member

Choose a reason for hiding this comment

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

My only comment is whether or not this should be in another package like org.elasticsearch.mocksocket? In general we should avoid split packages, and in a JDK 9 world, split packages are a thing that we are definitely not going to want to do. What do you think @s1monw?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't follow, what do you mean by split packages? this is unrelated to this PR no? I mean we need to fix this in MockSocket? Y

Copy link
Member

Choose a reason for hiding this comment

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

Split packages are packages that live in two jars. Yes, it needs to be fixed in mocksocket but this seemed a good place to raise the conversation.

@clintongormley clintongormley added :Distributed Coordination/Network Http and internode communication implementations >enhancement labels Dec 21, 2016
@Tim-Brooks
Copy link
Contributor Author

I made a few changes to this PR:

  1. I placed the classes in a mocksocket package to attempt to address @jasontedor's concern.
  2. I added wrappers for HttpServer and HttpsServer. This addresses the problem where those classes do not wrap accept() in doPrivilege().

The mocksocket project is in MavenCentral. So once this passes an updated review, it should be good to merge in.

@Tim-Brooks Tim-Brooks force-pushed the integrate_mocksocket branch from 6d53178 to 3c32279 Compare January 2, 2017 17:20
@Tim-Brooks
Copy link
Contributor Author

I updated this PR with a new version of mocksocket that adds a method needed for "connect" permissions.

And I rebased it on current master.

@Tim-Brooks Tim-Brooks changed the title Replace Socket and ServerSocket usages in tests with mocksocket versions Replace Socket, ServerSocket, and HttpServer usages in tests with mocksocket versions Jan 2, 2017
@s1monw
Copy link
Contributor

s1monw commented Jan 3, 2017

LGTM

Copy link
Member

@jasontedor jasontedor left a comment

Choose a reason for hiding this comment

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

LGTM.

@Tim-Brooks Tim-Brooks merged commit be22a25 into elastic:master Jan 4, 2017
@Tim-Brooks Tim-Brooks deleted the integrate_mocksocket branch January 4, 2017 20:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Distributed Coordination/Network Http and internode communication implementations >enhancement v6.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants