diff options
author | Stefan Seelmann <mail@stefan-seelmann.de> | 2021-02-13 17:38:50 +0300 |
---|---|---|
committer | Stefan Seelmann <mail@stefan-seelmann.de> | 2021-02-13 17:38:50 +0300 |
commit | a40fdf5d154ec9add0db5b6fe902b6bb0d2bc15e (patch) | |
tree | 94e980e23a4323fe8730bb7f3faf36094501728b /plugins | |
parent | a00e79c61fa90bc42a814bdccdeace12f65247c3 (diff) |
Handle non-existing connection file in fresh workspace
Diffstat (limited to 'plugins')
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 942ebad42..ee39b2535 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 a1fddb173..d509d29a2 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 ) |