--- a/jdk/src/java.base/share/classes/sun/net/www/protocol/ftp/FtpURLConnection.java Mon Apr 04 10:45:56 2016 -0700
+++ b/jdk/src/java.base/share/classes/sun/net/www/protocol/ftp/FtpURLConnection.java Tue Apr 05 17:07:56 2016 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -299,6 +299,13 @@
// Just keep throwing for now.
throw e;
} catch (FtpProtocolException fe) {
+ if (ftp != null) {
+ try {
+ ftp.close();
+ } catch (IOException ioe) {
+ fe.addSuppressed(ioe);
+ }
+ }
throw new IOException(fe);
}
try {
@@ -481,11 +488,34 @@
msgh.add("content-type", "text/plain");
msgh.add("access-type", "directory");
} catch (IOException ex) {
- throw new FileNotFoundException(fullpath);
+ FileNotFoundException fnfe = new FileNotFoundException(fullpath);
+ if (ftp != null) {
+ try {
+ ftp.close();
+ } catch (IOException ioe) {
+ fnfe.addSuppressed(ioe);
+ }
+ }
+ throw fnfe;
} catch (FtpProtocolException ex2) {
- throw new FileNotFoundException(fullpath);
+ FileNotFoundException fnfe = new FileNotFoundException(fullpath);
+ if (ftp != null) {
+ try {
+ ftp.close();
+ } catch (IOException ioe) {
+ fnfe.addSuppressed(ioe);
+ }
+ }
+ throw fnfe;
}
} catch (FtpProtocolException ftpe) {
+ if (ftp != null) {
+ try {
+ ftp.close();
+ } catch (IOException ioe) {
+ ftpe.addSuppressed(ioe);
+ }
+ }
throw new IOException(ftpe);
}
setProperties(msgh);