-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #285 from DataDog/prognant/fix-RMI-socket-connecti…
…on-timeout
- Loading branch information
Showing
3 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,3 +18,4 @@ target/* | |
|
||
# jenv | ||
.java_version | ||
.factorypath |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package org.datadog.jmxfetch; | ||
|
||
import java.io.IOException; | ||
import java.net.InetSocketAddress; | ||
import java.net.ServerSocket; | ||
import java.net.Socket; | ||
import java.rmi.server.RMISocketFactory; | ||
|
||
public class SocketFactory extends RMISocketFactory { | ||
private final int timeout; | ||
|
||
SocketFactory(final int timeout) { | ||
this.timeout = timeout; | ||
} | ||
|
||
@Override | ||
public Socket createSocket(final String host, final int port) throws IOException { | ||
final Socket socket = new Socket(); | ||
socket.connect(new InetSocketAddress(host, port), timeout); | ||
return socket; | ||
} | ||
|
||
@Override | ||
public ServerSocket createServerSocket(final int port) throws IOException { | ||
return new ServerSocket(port); | ||
} | ||
} |