|
1 | 1 | /*
|
2 |
| - * Copyright 2009-2023 the original author or authors. |
| 2 | + * Copyright 2009-2024 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
21 | 21 | import org.apache.ibatis.session.SqlSession;
|
22 | 22 | import org.apache.ibatis.session.SqlSessionFactory;
|
23 | 23 | import org.apache.ibatis.session.SqlSessionFactoryBuilder;
|
24 |
| -import org.apache.ibatis.util.LockKit; |
25 | 24 |
|
26 | 25 | public class IbatisConfig {
|
27 |
| - private static final LockKit.ComputedOnce computedOnce = new LockKit.ComputedOnce(); |
| 26 | + |
28 | 27 | private static SqlSessionFactory sqlSessionFactory;
|
29 | 28 |
|
30 | 29 | private IbatisConfig() {
|
31 | 30 | }
|
32 | 31 |
|
33 |
| - private static void init() { |
34 |
| - computedOnce.runOnce(() -> { |
35 |
| - if (sqlSessionFactory == null) { |
36 |
| - try { |
37 |
| - final String resource = "org/apache/ibatis/submitted/primitive_result_type/ibatis.xml"; |
38 |
| - Reader reader = Resources.getResourceAsReader(resource); |
39 |
| - sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader); |
40 |
| - } catch (Exception e) { |
41 |
| - throw new RuntimeException(e); |
42 |
| - } |
| 32 | + private static synchronized void init() { |
| 33 | + if (sqlSessionFactory == null) { |
| 34 | + try { |
| 35 | + final String resource = "org/apache/ibatis/submitted/primitive_result_type/ibatis.xml"; |
| 36 | + Reader reader = Resources.getResourceAsReader(resource); |
| 37 | + sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader); |
| 38 | + } catch (Exception e) { |
| 39 | + throw new RuntimeException(e); |
43 | 40 | }
|
44 |
| - }); |
| 41 | + } |
45 | 42 | }
|
46 | 43 |
|
47 | 44 | public static SqlSession getSession() {
|
|
0 commit comments