diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 7b2f346..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,62 +0,0 @@ -name: CI - -on: - push: - branches: [ master ] - paths: - - '.github/workflows/ci.yml' - - '**/pom.xml' - - '**/src/main/**' - - '**/src/test/**' - pull_request: - branches: [ master ] - paths: - - '.github/workflows/ci.yml' - - '**/pom.xml' - - '**/src/main/**' - - '**/src/test/**' - -concurrency: - group: ${{ github.event_name }}-${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -env: - MAVEN_OPTS: -Dhttps.protocols=TLSv1.2 -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true - -jobs: - core-ci: - name: Core CI - JDK ${{ matrix.java-version }} on ${{ matrix.os }} - runs-on: ${{ matrix.os }} - timeout-minutes: 60 - strategy: - matrix: - os: [ ubuntu-latest ] - java-version: [ 8 ] - steps: - - uses: actions/checkout@v3 - - name: Setup java - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: ${{ matrix.java-version }} - cache: 'maven' - - name: Build core with Maven - run: ./mvnw -am -pl core -B clean package - test-ci: - name: Test CI - JDK ${{ matrix.java-version }} on ${{ matrix.os }} - runs-on: ${{ matrix.os }} - timeout-minutes: 60 - strategy: - matrix: - os: [ ubuntu-latest ] - java-version: [ 17, 19 ] - steps: - - uses: actions/checkout@v3 - - name: Setup java - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: ${{ matrix.java-version }} - cache: 'maven' - - name: Build javax test with Maven - run: ./mvnw -am -pl test/javax -B clean test \ No newline at end of file diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml deleted file mode 100644 index 2de5fc8..0000000 --- a/.github/workflows/codeql.yml +++ /dev/null @@ -1,76 +0,0 @@ -# For most projects, this workflow file will not need changing; you simply need -# to commit it to your repository. -# -# You may wish to alter this file to override the set of languages analyzed, -# or to provide custom queries or build logic. -# -# ******** NOTE ******** -# We have attempted to detect the languages in your repository. Please check -# the `language` matrix defined below to confirm you have the correct set of -# supported CodeQL languages. -# -name: "CodeQL" - -on: - push: - branches: [ "master" ] - pull_request: - # The branches below must be a subset of the branches above - branches: [ "master" ] - schedule: - - cron: '33 1 * * 3' - -jobs: - analyze: - name: Analyze - runs-on: ubuntu-latest - permissions: - actions: read - contents: read - security-events: write - - strategy: - fail-fast: false - matrix: - language: [ 'java' ] - # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] - # Use only 'java' to analyze code written in Java, Kotlin or both - # Use only 'javascript' to analyze code written in JavaScript, TypeScript or both - # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v2 - with: - languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. - - # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs - # queries: security-extended,security-and-quality - - - # Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v2 - - # â„šī¸ Command-line programs to run using the OS shell. - # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun - - # If the Autobuild fails above, remove it and uncomment the following three lines. - # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. - - # - run: | - # echo "Run, Build Application using script" - # ./location_of_script_within_repo/buildscript.sh - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 - with: - category: "/language:${{matrix.language}}" diff --git a/dynamic-datasource-spring/src/main/java/com/baomidou/dynamic/datasource/creator/druid/DruidConfig.java b/dynamic-datasource-spring/src/main/java/com/baomidou/dynamic/datasource/creator/druid/DruidConfig.java index 7c69c4a..586f1d7 100644 --- a/dynamic-datasource-spring/src/main/java/com/baomidou/dynamic/datasource/creator/druid/DruidConfig.java +++ b/dynamic-datasource-spring/src/main/java/com/baomidou/dynamic/datasource/creator/druid/DruidConfig.java @@ -37,6 +37,7 @@ public class DruidConfig { private Integer maxWait; private Long timeBetweenEvictionRunsMillis; private Long timeBetweenLogStatsMillis; + private Long keepAliveBetweenTimeMillis; private Integer statSqlMaxSize; private Long minEvictableIdleTimeMillis; private Long maxEvictableIdleTimeMillis; @@ -58,6 +59,8 @@ public class DruidConfig { private Integer maxWaitThreadCount; private Boolean failFast; private Long phyTimeoutMillis; + private Long phyMaxUseCount; + private Boolean keepAlive; private Boolean poolPreparedStatements; private Boolean initVariants; @@ -73,12 +76,12 @@ public class DruidConfig { private Boolean removeAbandoned; private Integer removeAbandonedTimeoutMillis; private Boolean logAbandoned; - private Integer queryTimeout; // second + private Integer queryTimeout; private Integer transactionQueryTimeout; private String publicKey; - private Integer connectTimeout; // millisecond - private Integer socketTimeout; // millisecond - private Long timeBetweenConnectErrorMillis; // millisecond + private Integer connectTimeout; + private Integer socketTimeout; + private Long timeBetweenConnectErrorMillis; private Map wall = new HashMap<>(); private Map slf4j = new HashMap<>(); @@ -129,6 +132,12 @@ public class DruidConfig { properties.setProperty(DruidConsts.TIME_BETWEEN_LOG_STATS_MILLIS, String.valueOf(timeBetweenLogStatsMillis)); } + Long keepAliveBetweenTimeMillis = + this.keepAliveBetweenTimeMillis == null ? g.getKeepAliveBetweenTimeMillis() : this.keepAliveBetweenTimeMillis; + if (keepAliveBetweenTimeMillis != null && !keepAliveBetweenTimeMillis.equals(DruidAbstractDataSource.DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS * 2)) { + properties.setProperty(DruidConsts.KEEPALIVE_BETWEEN_TIME_MILLIS, String.valueOf(keepAliveBetweenTimeMillis)); + } + Long minEvictableIdleTimeMillis = this.minEvictableIdleTimeMillis == null ? g.getMinEvictableIdleTimeMillis() : this.minEvictableIdleTimeMillis; if (minEvictableIdleTimeMillis != null && !minEvictableIdleTimeMillis.equals(DruidAbstractDataSource.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS)) { @@ -207,6 +216,11 @@ public class DruidConfig { properties.setProperty(DruidConsts.PHY_TIMEOUT_MILLIS, String.valueOf(phyTimeoutMillis)); } + Long phyMaxUseCount = this.phyMaxUseCount == null ? g.getPhyMaxUseCount() : this.phyMaxUseCount; + if (phyMaxUseCount != null && !phyMaxUseCount.equals(-1)) { + properties.setProperty(DruidConsts.PHY_MAX_USE_COUNT, String.valueOf(phyMaxUseCount)); + } + Boolean keepAlive = this.keepAlive == null ? g.getKeepAlive() : this.keepAlive; if (keepAlive != null && keepAlive.equals(Boolean.TRUE)) { properties.setProperty(DruidConsts.KEEP_ALIVE, Boolean.TRUE.toString()); diff --git a/dynamic-datasource-spring/src/main/java/com/baomidou/dynamic/datasource/creator/druid/DruidConsts.java b/dynamic-datasource-spring/src/main/java/com/baomidou/dynamic/datasource/creator/druid/DruidConsts.java index b608738..a19e142 100644 --- a/dynamic-datasource-spring/src/main/java/com/baomidou/dynamic/datasource/creator/druid/DruidConsts.java +++ b/dynamic-datasource-spring/src/main/java/com/baomidou/dynamic/datasource/creator/druid/DruidConsts.java @@ -32,6 +32,7 @@ public interface DruidConsts { String TIME_BETWEEN_LOG_STATS_MILLIS = "druid.timeBetweenLogStatsMillis"; String MIN_EVICTABLE_IDLE_TIME_MILLIS = "druid.minEvictableIdleTimeMillis"; String MAX_EVICTABLE_IDLE_TIME_MILLIS = "druid.maxEvictableIdleTimeMillis"; + String KEEPALIVE_BETWEEN_TIME_MILLIS = "druid.keepAliveBetweenTimeMillis"; String TEST_WHILE_IDLE = "druid.testWhileIdle"; String TEST_ON_BORROW = "druid.testOnBorrow"; @@ -47,6 +48,7 @@ public interface DruidConsts { String FAIL_FAST = "druid.failFast"; String PHY_TIMEOUT_MILLIS = "druid.phyTimeoutMillis"; + String PHY_MAX_USE_COUNT = "druid.phyMaxUseCount"; String KEEP_ALIVE = "druid.keepAlive"; String POOL_PREPARED_STATEMENTS = "druid.poolPreparedStatements"; String INIT_VARIANTS = "druid.initVariants";