Skip to content

Commit

Permalink
Remove WrapException
Browse files Browse the repository at this point in the history
  • Loading branch information
terrymanu committed Oct 31, 2023
1 parent bdd7637 commit 4da66aa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.apache.shardingsphere.elasticjob.kernel.tracing.event.JobExecutionEvent;
import org.apache.shardingsphere.elasticjob.kernel.tracing.event.JobStatusTraceEvent;
import org.apache.shardingsphere.elasticjob.kernel.tracing.event.JobStatusTraceEvent.State;
import org.apache.shardingsphere.elasticjob.kernel.tracing.exception.WrapException;
import org.apache.shardingsphere.elasticjob.kernel.tracing.exception.TracingStorageUnavailableException;
import org.apache.shardingsphere.elasticjob.tracing.rdb.storage.sql.RDBStorageSQLMapper;
import org.apache.shardingsphere.elasticjob.tracing.rdb.storage.sql.SQLPropertiesFactory;
import org.apache.shardingsphere.elasticjob.tracing.rdb.storage.type.TracingStorageDatabaseType;
Expand Down Expand Up @@ -69,26 +69,26 @@ private RDBJobEventRepository(final DataSource dataSource) throws SQLException {
}

/**
* The same dataSource always return the same RDBJobEventStorage instance.
* The same data source always return the same RDB job event repository instance.
*
* @param dataSource dataSource
* @return RDBJobEventStorage instance
* @throws SQLException SQLException
*/
public static RDBJobEventRepository getInstance(final DataSource dataSource) throws SQLException {
return wrapException(() -> STORAGE_MAP.computeIfAbsent(dataSource, ds -> {
return getInstance(() -> STORAGE_MAP.computeIfAbsent(dataSource, ds -> {
try {
return new RDBJobEventRepository(ds);
} catch (final SQLException ex) {
throw new WrapException(ex);
throw new TracingStorageUnavailableException(ex);
}
}));
}

private static RDBJobEventRepository wrapException(final Supplier<RDBJobEventRepository> supplier) throws SQLException {
private static RDBJobEventRepository getInstance(final Supplier<RDBJobEventRepository> supplier) throws SQLException {
try {
return supplier.get();
} catch (final WrapException ex) {
} catch (final TracingStorageUnavailableException ex) {
if (ex.getCause() instanceof SQLException) {
throw new SQLException(ex.getCause());
}
Expand Down

This file was deleted.

0 comments on commit 4da66aa

Please sign in to comment.