mirror of
				https://github.com/vran-dev/databasir.git
				synced 2025-11-04 16:26:10 +08:00 
			
		
		
		
	fix: npe when sync project
This commit is contained in:
		@@ -54,7 +54,8 @@ public class ProjectSyncTaskScheduler {
 | 
				
			|||||||
            updateSyncTaskStatus(taskId, ProjectSyncTaskStatus.FINISHED, "ok");
 | 
					            updateSyncTaskStatus(taskId, ProjectSyncTaskStatus.FINISHED, "ok");
 | 
				
			||||||
            saveOperationLog(projectId, userId, null);
 | 
					            saveOperationLog(projectId, userId, null);
 | 
				
			||||||
        } catch (Exception e) {
 | 
					        } catch (Exception e) {
 | 
				
			||||||
            updateSyncTaskStatus(taskId, ProjectSyncTaskStatus.FAILED, e.getMessage());
 | 
					            String result = Objects.requireNonNullElse(e.getMessage(), "unknown");
 | 
				
			||||||
 | 
					            updateSyncTaskStatus(taskId, ProjectSyncTaskStatus.FAILED, result);
 | 
				
			||||||
            saveOperationLog(projectId, userId, e);
 | 
					            saveOperationLog(projectId, userId, e);
 | 
				
			||||||
            throw e;
 | 
					            throw e;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -143,13 +143,16 @@ public class DocumentService {
 | 
				
			|||||||
        databasirConfig.setIgnoreTableNameRegex(jsonConverter.fromJson(rule.getIgnoreTableNameRegexArray()));
 | 
					        databasirConfig.setIgnoreTableNameRegex(jsonConverter.fromJson(rule.getIgnoreTableNameRegexArray()));
 | 
				
			||||||
        databasirConfig.setIgnoreTableColumnNameRegex(jsonConverter.fromJson(rule.getIgnoreColumnNameRegexArray()));
 | 
					        databasirConfig.setIgnoreTableColumnNameRegex(jsonConverter.fromJson(rule.getIgnoreColumnNameRegexArray()));
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
 | 
					            if (jdbcConnection == null) {
 | 
				
			||||||
 | 
					                throw DomainErrors.CONNECT_DATABASE_FAILED.exception();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
            DatabaseMeta databaseMeta = Databasir.of(databasirConfig)
 | 
					            DatabaseMeta databaseMeta = Databasir.of(databasirConfig)
 | 
				
			||||||
                    .get(jdbcConnection, dataSource.getDatabaseName(), dataSource.getSchemaName())
 | 
					                    .get(jdbcConnection, dataSource.getDatabaseName(), dataSource.getSchemaName())
 | 
				
			||||||
                    .orElseThrow(DomainErrors.DATABASE_META_NOT_FOUND::exception);
 | 
					                    .orElseThrow(DomainErrors.DATABASE_META_NOT_FOUND::exception);
 | 
				
			||||||
            return databaseMeta;
 | 
					            return databaseMeta;
 | 
				
			||||||
        } finally {
 | 
					        } finally {
 | 
				
			||||||
            try {
 | 
					            try {
 | 
				
			||||||
                if (!jdbcConnection.isClosed()) {
 | 
					                if (jdbcConnection != null && !jdbcConnection.isClosed()) {
 | 
				
			||||||
                    jdbcConnection.close();
 | 
					                    jdbcConnection.close();
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            } catch (SQLException e) {
 | 
					            } catch (SQLException e) {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user