Merge remote-tracking branch 'upstream/trunk' into trunk
diff --git a/.travis.yml b/.travis.yml
index 41a3c86..cd98d6a 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -16,12 +16,10 @@
 language: java

 sudo: false

 

-dist: precise

-

 jdk:

-  - openjdk6

   - openjdk7

   - oraclejdk8

+  - oraclejdk9

 

 after_success:

   - mvn clean cobertura:cobertura coveralls:report

diff --git a/pom.xml b/pom.xml
index 45f3b11..1564aed 100644
--- a/pom.xml
+++ b/pom.xml
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.apache.commons</groupId>
         <artifactId>commons-parent</artifactId>
-        <version>42</version>
+        <version>43</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
     <groupId>commons-net</groupId>
@@ -235,6 +235,11 @@
                     <excludes>
                         <exclude>**/examples/**</exclude>
                     </excludes>
+                    <archive combine.children="append">
+                        <manifestEntries>
+                            <Automatic-Module-Name>${commons.module.name}</Automatic-Module-Name>
+                        </manifestEntries>
+                    </archive>
                 </configuration>
             </plugin>
 
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index d23b05f..bbaf6c2 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -74,6 +74,12 @@
  The examples are not part of the public API, so this does not affect compatibility.
 
 ">
+            <action issue="NET-643" type="fix" dev="sebb" due-to="Vasily">
+            NPE when closing telnet stream
+            </action>
+            <action issue="NET-648" type="add" dev="pschumacher">
+            Add Automatic-Module-Name MANIFEST entry for Java 9 compatibility
+            </action>
             <action issue="NET-641" type="fix" dev="sebb" due-to="pin_ptr">
             SubnetUtils.SubnetInfo.isInRange("0.0.0.0") returns true for CIDR/31, 32
             </action>
diff --git a/src/main/java/org/apache/commons/net/ftp/FTPSSocketFactory.java b/src/main/java/org/apache/commons/net/ftp/FTPSSocketFactory.java
index b148180..d24405d 100644
--- a/src/main/java/org/apache/commons/net/ftp/FTPSSocketFactory.java
+++ b/src/main/java/org/apache/commons/net/ftp/FTPSSocketFactory.java
@@ -27,7 +27,7 @@
 
 /**
  *
- * Implementation of org.apache.commons.net.SocketFactory
+ * Socket factory for FTPS connections.
  *
  * @since 2.0
  */
diff --git a/src/main/java/org/apache/commons/net/telnet/TelnetClient.java b/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
index ac1e49d..d113276 100644
--- a/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
+++ b/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
@@ -100,10 +100,16 @@
 
     void _flushOutputStream() throws IOException
     {
+        if (_output_ == null) {
+            throw new IOException("Stream closed");
+        }
         _output_.flush();
     }
     void _closeOutputStream() throws IOException
     {
+        if (_output_ == null) {
+            return;
+        }
         try {
             _output_.close();
         } finally {