From 3c82728571afa83fefd594343170dc31c275a8b6 Mon Sep 17 00:00:00 2001
Date: Fri, 22 Jan 2021 16:28:31 +0800
Subject: 8231631: sun/net/ftp/FtpURLConnectionLeak.java fails
 intermittently with NPE

Summary: <sun.net>: sun/net/www/ftptest/FtpCommandHandler.java is modified to handle EOF properly
LLT: jdk8u/jdk/test/sun/net/ftp/FtpURLConnectionLeak.java
Bug url: https://bugs.openjdk.java.net/browse/JDK-8231631 #2468
---
 jdk/test/sun/net/www/ftptest/FtpCommandHandler.java | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/jdk/test/sun/net/www/ftptest/FtpCommandHandler.java b/jdk/test/sun/net/www/ftptest/FtpCommandHandler.java
index 151b3df8e..f6c87d5a4 100644
--- a/jdk/test/sun/net/www/ftptest/FtpCommandHandler.java
+++ b/jdk/test/sun/net/www/ftptest/FtpCommandHandler.java
@@ -458,6 +458,10 @@ public class FtpCommandHandler extends Thread {
             try {
                 str = in.readLine();
                 System.out.println("line: " + str);
+                if (str == null) {
+                    System.out.println("EOF read from input");
+                    break;
+                }
                 buf = new StringBuffer(str);
                 res = parseCmd(buf);
                 switch (res) {
-- 
2.19.0

