You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by se...@apache.org on 2021/02/13 14:39:06 UTC

[directory-studio] branch master updated: Handle non-existing connection file in fresh workspace

This is an automated email from the ASF dual-hosted git repository.

seelmann pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/directory-studio.git


The following commit(s) were added to refs/heads/master by this push:
     new a40fdf5  Handle non-existing connection file in fresh workspace
a40fdf5 is described below

commit a40fdf5d154ec9add0db5b6fe902b6bb0d2bc15e
Author: Stefan Seelmann <ma...@stefan-seelmann.de>
AuthorDate: Sat Feb 13 15:38:50 2021 +0100

    Handle non-existing connection file in fresh workspace
---
 .../connection/core/ConnectionFolderManager.java     | 20 ++++++++++++--------
 .../studio/connection/core/ConnectionManager.java    | 20 ++++++++++++--------
 2 files changed, 24 insertions(+), 16 deletions(-)

diff --git a/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/ConnectionFolderManager.java b/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/ConnectionFolderManager.java
index 942ebad..ee39b25 100644
--- a/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/ConnectionFolderManager.java
+++ b/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/ConnectionFolderManager.java
@@ -409,15 +409,19 @@ public class ConnectionFolderManager implements ConnectionUpdateListener
     {
         ConnectionEventRegistry.suspendEventFiringInCurrentThread();
 
-        try ( FileInputStream fileInputStream = new FileInputStream( getConnectionFolderStoreFileName() ) )
-        {
-            folderList = ConnectionIO.loadConnectionFolders( fileInputStream );
-        }
-        catch ( Exception e )
+        File file = new File( getConnectionFolderStoreFileName() );
+        if ( file.exists() )
         {
-            Status status = new Status( IStatus.ERROR, ConnectionCoreConstants.PLUGIN_ID,
-                Messages.error__saving_connections + e.getMessage(), e );
-            ConnectionCorePlugin.getDefault().getLog().log( status );
+            try ( FileInputStream fileInputStream = new FileInputStream( file ) )
+            {
+                folderList = ConnectionIO.loadConnectionFolders( fileInputStream );
+            }
+            catch ( Exception e )
+            {
+                Status status = new Status( IStatus.ERROR, ConnectionCoreConstants.PLUGIN_ID,
+                    Messages.error__loading_connections + e.getMessage(), e );
+                ConnectionCorePlugin.getDefault().getLog().log( status );
+            }
         }
 
         if ( !folderList.isEmpty() )
diff --git a/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/ConnectionManager.java b/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/ConnectionManager.java
index a1fddb1..d509d29 100644
--- a/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/ConnectionManager.java
+++ b/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/ConnectionManager.java
@@ -408,15 +408,19 @@ public class ConnectionManager implements ConnectionUpdateListener
     {
         Set<ConnectionParameter> connectionParameters = null;
 
-        try ( FileInputStream fileInputStream = new FileInputStream( getConnectionStoreFileName() ) )
-        {
-            connectionParameters = ConnectionIO.load( fileInputStream );
-        }
-        catch ( Exception e )
+        File file = new File( getConnectionStoreFileName() );
+        if ( file.exists() )
         {
-            Status status = new Status( IStatus.ERROR, ConnectionCoreConstants.PLUGIN_ID,
-                Messages.error__loading_connections + e.getMessage(), e );
-            ConnectionCorePlugin.getDefault().getLog().log( status );
+            try ( FileInputStream fileInputStream = new FileInputStream( file ) )
+            {
+                connectionParameters = ConnectionIO.load( fileInputStream );
+            }
+            catch ( Exception e )
+            {
+                Status status = new Status( IStatus.ERROR, ConnectionCoreConstants.PLUGIN_ID,
+                    Messages.error__loading_connections + e.getMessage(), e );
+                ConnectionCorePlugin.getDefault().getLog().log( status );
+            }
         }
 
         if ( connectionParameters != null )