Skip to content

Commit

Permalink
Missing files
Browse files Browse the repository at this point in the history
  • Loading branch information
ValentinZakharov committed Sep 25, 2024
1 parent 0a8eeb8 commit 1f95673
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package datadog.smoketest.appsec.springboot;

import java.util.concurrent.Executor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

@Configuration
@EnableAsync
public class AsyncConfig {
@Bean(name = "taskExecutor")
public Executor taskExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(5);
executor.setMaxPoolSize(10);
executor.setQueueCapacity(100);
executor.setThreadNamePrefix("Async-");
executor.initialize();
return executor;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package datadog.smoketest.appsec.springboot;

import java.sql.Connection;
import java.sql.DriverManager;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

@Service
public class MyAsyncService {

@Async("taskExecutor")
public void performAsyncTask(String id) {
try {
Connection conn = DriverManager.getConnection("jdbc:h2:mem:testdb", "sa", "");
conn.createStatement().execute("SELECT 1 FROM DUAL WHERE '1' = '" + id + "'");
} catch (Exception e) {
// ignore
}
}
}

0 comments on commit 1f95673

Please sign in to comment.