Skip to content

Commit

Permalink
Merge stable-2.x into master (#107)
Browse files Browse the repository at this point in the history
* [maven-release-plugin] prepare release remoting-2.62

* [maven-release-plugin] prepare for next development iteration

* [FIXED JENKINS-37539] - Prevent NPE in Engine#connect() when host or port are null or empty (#101)

Bug diagnosis:
* https://scan8.coverity.com/reports.htm#v14462/p10499/fileInstanceId=12836372&defectInstanceId=4427367&mergedDefectId=152195
* https://scan8.coverity.com/reports.htm#v14462/p10499/fileInstanceId=12836372&defectInstanceId=4427365&mergedDefectId=152194

* [CID-152201] - Fix resource leak in remoting.jnlp.Main (#102)

* [CID-152200,CID-152202] - Resource leak in Cipher I/O streams on exceptional paths (#104)

* [CID-152200,CID-152202] - Resource leak in Cipher I/O streams on exceptional paths

* https://scan8.coverity.com/reports.htm#v14462/p10499/fileInstanceId=12836377&defectInstanceId=4427377&mergedDefectId=152202
* https://scan8.coverity.com/reports.htm#v14462/p10499/fileInstanceId=12836377&defectInstanceId=4427377&mergedDefectId=152200

* [CID-152202] - Fix typo noticed by @olivergondza

* Fix another merge conflict

* Remove EngineUtil#closeAndLogFailures()
  • Loading branch information
oleg-nenashev committed Sep 26, 2016
1 parent 89c0896 commit 190653b
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 8 deletions.
5 changes: 4 additions & 1 deletion src/main/java/hudson/remoting/Engine.java
Expand Up @@ -23,6 +23,7 @@
*/
package hudson.remoting;

import edu.umd.cs.findbugs.annotations.Nullable;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import hudson.remoting.Channel.Mode;
import java.io.File;
Expand Down Expand Up @@ -453,8 +454,10 @@ private void onConnectionRejected(String greeting) throws InterruptedException {

/**
* Connects to TCP slave host:port, with a few retries.
* @param endpoint Connection endpoint
* @throws IOException Connection failure or invalid parameter specification
*/
private Socket connect(JnlpAgentEndpoint endpoint) throws IOException, InterruptedException {
private Socket connect(@Nonnull JnlpAgentEndpoint endpoint) throws IOException, InterruptedException {

String msg = "Connecting to " + endpoint.getHost() + ':' + endpoint.getPort();
events.status(msg);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/hudson/remoting/Util.java
Expand Up @@ -128,7 +128,7 @@ static String indent(String s) {
*
* Warning: this method won't match shortened representation of IPV6 address
*/
static boolean inNoProxyEnvVar(String host) {
static boolean inNoProxyEnvVar(@Nonnull String host) {
String noProxy = System.getenv("no_proxy");
if (noProxy != null) {
noProxy = noProxy.trim()
Expand Down
12 changes: 7 additions & 5 deletions src/main/java/hudson/remoting/jnlp/Main.java
Expand Up @@ -191,14 +191,18 @@ public Engine createEngine() {
if (file.isFile()
&& (length = file.length()) < 65536
&& length > "-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----".length()) {
FileInputStream fis = null;
try {
// we do basic size validation, if there are x509 certificates that have a PEM encoding
// larger
// than 64kb we can revisit the upper bound.
cert = new byte[(int) length];
fis = new FileInputStream(file);
int read = fis.read(cert);
FileInputStream fis = new FileInputStream(file);
final int read;
try {
read = fis.read(cert);
} finally {
fis.close();
}
if (cert.length != read) {
LOGGER.log(Level.WARNING, "Only read {0} bytes from {1}, expected to read {2}",
new Object[]{read, file, cert.length});
Expand All @@ -208,8 +212,6 @@ public Engine createEngine() {
} catch (IOException e) {
LOGGER.log(Level.WARNING, "Could not read certificate from " + file, e);
continue;
} finally {
IOUtils.closeQuietly(fis);
}
} else {
if (file.isFile()) {
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/org/jenkinsci/remoting/engine/EngineUtil.java
Expand Up @@ -24,9 +24,14 @@
package org.jenkinsci.remoting.engine;

import java.io.ByteArrayOutputStream;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
* Engine utility methods.
Expand Down
Expand Up @@ -282,7 +282,8 @@ public void waitForReady() throws InterruptedException {

}

static InetSocketAddress getResolvedHttpProxyAddress(String host, int port) throws IOException {
@CheckForNull
static InetSocketAddress getResolvedHttpProxyAddress(@Nonnull String host, int port) throws IOException {
InetSocketAddress targetAddress = null;
Iterator<Proxy>
proxies =
Expand Down

1 comment on commit 190653b

@oleg-nenashev
Copy link
Member Author

Choose a reason for hiding this comment

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

Seems somethis has been messed up. It's not actually a merge commit

Please sign in to comment.