JDK-8210696-branch: fix loadCaptureFile exception swallowing JDK-8210696-branch
authorxyin
Mon, 06 May 2019 14:23:32 +0800
branchJDK-8210696-branch
changeset 57351 b9e5f8090688
parent 57346 3efc6cb7ffdb
JDK-8210696-branch: fix loadCaptureFile exception swallowing
test/jdk/com/sun/jndi/ldap/lib/BaseLdapServer.java
test/jdk/com/sun/jndi/ldap/lib/LdapPlaybackServer.java
--- a/test/jdk/com/sun/jndi/ldap/lib/BaseLdapServer.java	Wed May 01 15:10:09 2019 +0100
+++ b/test/jdk/com/sun/jndi/ldap/lib/BaseLdapServer.java	Mon May 06 14:23:32 2019 +0800
@@ -161,8 +161,8 @@
      */
     @Override
     public synchronized void start() {
+        isRunning = true;
         super.start();
-        isRunning = true;
     }
 
     /**
--- a/test/jdk/com/sun/jndi/ldap/lib/LdapPlaybackServer.java	Wed May 01 15:10:09 2019 +0100
+++ b/test/jdk/com/sun/jndi/ldap/lib/LdapPlaybackServer.java	Mon May 06 14:23:32 2019 +0800
@@ -60,13 +60,16 @@
      */
     private final Map<Integer, List<byte[]>> cache = new HashMap<>();
 
-    private String fileName;
-
     public LdapPlaybackServer(ServerSocket serverSocket, String fileName) {
         super(serverSocket);
-        this.fileName = fileName;
         setDebugLevel(DebugLevel.CUSTOMIZE, this.getClass());
         setCommonRequestHandler(this::handleRequest);
+        try {
+            debug("Loading LDAP cache from: " + fileName);
+            loadCaptureFile(fileName);
+        } catch (IOException e) {
+            throw new RuntimeException("ERROR: failed to load LDAP cache", e);
+        }
     }
 
     /*
@@ -167,10 +170,7 @@
     @Override
     public void run() {
         try {
-            debug("Loading LDAP cache from: " + fileName);
-            loadCaptureFile(fileName);
             debug("listening on port " + getPort());
-
             super.run();
         } catch (Exception e) {
             debug("ERROR: " + e);