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

Projects
None yet
4 participants
@tbrooks8
Copy link
Contributor

commented Dec 20, 2016

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.

@tbrooks8 tbrooks8 requested review from s1monw and jasontedor Dec 20, 2016

@tbrooks8

This comment has been minimized.

Copy link
Contributor Author

commented Dec 20, 2016

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

I should get to today or tomorrow.

@s1monw

s1monw approved these changes Dec 20, 2016

Copy link
Contributor

left a comment

this PR LGTM provided MockSocket is available publicially

@jasontedor
Copy link
Member

left a comment

I left one comment.

...tty4/src/test/java/org/elasticsearch/transport/netty4/Netty4SizeHeaderFrameDecoderTests.java Outdated
@@ -19,6 +19,7 @@

package org.elasticsearch.transport.netty4;

import org.elasticsearch.MockSocket;

This comment has been minimized.

Copy link
@jasontedor

jasontedor Dec 20, 2016

Member

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?

This comment has been minimized.

Copy link
@s1monw

s1monw Dec 21, 2016

Contributor

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

This comment has been minimized.

Copy link
@jasontedor

jasontedor Dec 21, 2016

Member

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.

@tbrooks8 tbrooks8 force-pushed the tbrooks8:integrate_mocksocket branch Dec 27, 2016

@tbrooks8

This comment has been minimized.

Copy link
Contributor Author

commented Dec 28, 2016

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.

@tbrooks8 tbrooks8 force-pushed the tbrooks8:integrate_mocksocket branch to 3c32279 Jan 2, 2017

@tbrooks8

This comment has been minimized.

Copy link
Contributor Author

commented Jan 2, 2017

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.

@tbrooks8 tbrooks8 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

This comment has been minimized.

Copy link
Contributor

commented Jan 3, 2017

LGTM

@jasontedor
Copy link
Member

left a comment

LGTM.

@tbrooks8 tbrooks8 merged commit be22a25 into elastic:master Jan 4, 2017

2 checks passed

CLA Commit author is a member of Elasticsearch
Details
elasticsearch-ci Build finished.
Details

@tbrooks8 tbrooks8 deleted the tbrooks8:integrate_mocksocket branch Jan 4, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.