@@ -138,7 +138,7 @@ public void save(String filePath, PropertiesConfiguration config) {
138138 @ Override
139139 public void saveDBConnectionInfo (String filePath , Map <String , JdbcConnectionInfo > dbConfig ) {
140140 PropertiesConfiguration config = connInfoConfig ;
141-
141+
142142 // TODO dbnames property..
143143 String dbNames = "" ;
144144 for (String dbName : dbConfig .keySet ()) {
@@ -153,8 +153,9 @@ public void saveDBConnectionInfo(String filePath, Map<String, JdbcConnectionInfo
153153 config .setProperty (dbName + ".jdbc.validation" , jdbc .getJdbcValidation ());
154154 config .setProperty (dbName + ".jdbc.connections" , jdbc .getJdbcConnections ());
155155 }
156-
157- config .setProperty ("dbnames" , dbNames .substring (0 , dbNames .length () - 1 ));
156+
157+ String newDbNames = dbNames .length () == 0 ? "" : dbNames .substring (0 , dbNames .length () - 1 );
158+ config .setProperty ("dbnames" , newDbNames );
158159
159160 PropertiesConfigurationLayout layout = config .getLayout ();
160161 try {
@@ -213,7 +214,9 @@ public void saveServerConnectionInfo(String filePath, Map<String, JschConnection
213214 config .setProperty (serverName + ".server.alertlog.filepath" , jsch .getAlc ().getReadFilePath ());
214215 config .setProperty (serverName + ".server.alertlog.readline" , 500 );
215216 }
216- config .setProperty ("servernames" , serverNames .substring (0 , serverNames .length () - 1 ));
217+
218+ String newServerNames = serverNames .length () == 0 ? "" : serverNames .substring (0 , serverNames .length () - 1 );
219+ config .setProperty ("servernames" , newServerNames );
217220
218221 PropertiesConfigurationLayout layout = config .getLayout ();
219222 try {
0 commit comments