New upstream version 1.7.30
Emmanuel Bourg
2 years ago
55 | 55 | <pathelement location="../slf4j-simple/target/slf4j-simple-${currentVersion}.jar" /> |
56 | 56 | </path > |
57 | 57 | |
58 | ||
58 | <path id="pathNoBinding"> | |
59 | <pathelement location="target/test-classes/" /> | |
60 | <pathelement location="../slf4j-api/target/slf4j-api-${currentVersion}.jar" /> | |
61 | </path > | |
62 | ||
63 | ||
59 | 64 | <path id="incompatibleMultiBinding"> |
60 | 65 | <pathelement location="target/test-classes/" /> |
61 | 66 | <pathelement location="../slf4j-api/target/slf4j-api-${currentVersion}.jar" /> |
101 | 106 | </target> |
102 | 107 | |
103 | 108 | <target name="testAll" depends="init, |
104 | testMissingSingletonMethod, | |
109 | testMissingSingletonMethod, | |
105 | 110 | testMismatch, |
106 | testMatch, | |
107 | testMultiBinding, | |
108 | testIncompatibleMultiBinding, | |
111 | testNoBinding, | |
112 | testMatch, | |
113 | testMultiBinding, | |
114 | testIncompatibleMultiBinding, | |
109 | 115 | testFuture_16Series, |
110 | 116 | testActiveSecurityManager"> |
111 | 117 | </target> |
214 | 220 | </junit> |
215 | 221 | |
216 | 222 | </target> |
217 | ||
223 | ||
224 | <target name="testNoBinding"> | |
225 | <junit printsummary="yes" fork="no" haltonfailure="yes"> | |
226 | <classpath refid="pathNoBinding" /> | |
227 | <formatter type="plain" /> | |
228 | <test fork="yes" todir="target/unit-reports" | |
229 | outfile="TEST-NOBINDING" | |
230 | name="org.slf4j.helpers.NoBindingMultithreadedInitializationTest2" /> | |
231 | </junit> | |
232 | </target> | |
233 | ||
218 | 234 | |
219 | 235 | <condition property="runFromWithinIntegrationModule"> |
220 | 236 | <contains string="${user.dir}" substring="integration" /> |
6 | 6 | <parent> |
7 | 7 | <groupId>org.slf4j</groupId> |
8 | 8 | <artifactId>slf4j-parent</artifactId> |
9 | <version>1.7.29</version> | |
9 | <version>1.7.30</version> | |
10 | 10 | </parent> |
11 | 11 | |
12 | 12 | <artifactId>integration</artifactId> |
0 | /** | |
1 | * Copyright (c) 2004-2016 QOS.ch | |
2 | * All rights reserved. | |
3 | * | |
4 | * Permission is hereby granted, free of charge, to any person obtaining | |
5 | * a copy of this software and associated documentation files (the | |
6 | * "Software"), to deal in the Software without restriction, including | |
7 | * without limitation the rights to use, copy, modify, merge, publish, | |
8 | * distribute, sublicense, and/or sell copies of the Software, and to | |
9 | * permit persons to whom the Software is furnished to do so, subject to | |
10 | * the following conditions: | |
11 | * | |
12 | * The above copyright notice and this permission notice shall be | |
13 | * included in all copies or substantial portions of the Software. | |
14 | * | |
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | |
16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |
17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | |
18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | |
19 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | |
20 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | |
21 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
22 | * | |
23 | */ | |
24 | package org.slf4j.helpers; | |
25 | ||
26 | import java.util.List; | |
27 | import java.util.concurrent.CyclicBarrier; | |
28 | import java.util.concurrent.atomic.AtomicLong; | |
29 | ||
30 | import org.slf4j.Logger; | |
31 | import org.slf4j.LoggerFactory; | |
32 | ||
33 | public class LoggerAccessingThread2 extends Thread { | |
34 | private static int LOOP_LEN = 64; | |
35 | ||
36 | final CyclicBarrier barrier; | |
37 | final int count; | |
38 | final AtomicLong eventCount; | |
39 | List<Logger> loggerList; | |
40 | ||
41 | public LoggerAccessingThread2(final CyclicBarrier barrier, List<Logger> loggerList, final int count, final AtomicLong eventCount) { | |
42 | this.barrier = barrier; | |
43 | this.loggerList = loggerList; | |
44 | this.count = count; | |
45 | this.eventCount = eventCount; | |
46 | } | |
47 | ||
48 | public void run() { | |
49 | try { | |
50 | barrier.await(); | |
51 | } catch (Exception e) { | |
52 | e.printStackTrace(); | |
53 | } | |
54 | ||
55 | String loggerNamePrefix = this.getClass().getName(); | |
56 | for (int i = 0; i < LOOP_LEN; i++) { | |
57 | Logger logger = LoggerFactory.getLogger(loggerNamePrefix + "-" + count + "-" + i); | |
58 | loggerList.add(logger); | |
59 | Thread.yield(); | |
60 | logger.info("in run method"); | |
61 | eventCount.getAndIncrement(); | |
62 | } | |
63 | } | |
64 | } |
+112
-0
0 | /** | |
1 | * Copyright (c) 2004-2016 QOS.ch | |
2 | * All rights reserved. | |
3 | * | |
4 | * Permission is hereby granted, free of charge, to any person obtaining | |
5 | * a copy of this software and associated documentation files (the | |
6 | * "Software"), to deal in the Software without restriction, including | |
7 | * without limitation the rights to use, copy, modify, merge, publish, | |
8 | * distribute, sublicense, and/or sell copies of the Software, and to | |
9 | * permit persons to whom the Software is furnished to do so, subject to | |
10 | * the following conditions: | |
11 | * | |
12 | * The above copyright notice and this permission notice shall be | |
13 | * included in all copies or substantial portions of the Software. | |
14 | * | |
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | |
16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |
17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | |
18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | |
19 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | |
20 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | |
21 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
22 | * | |
23 | */ | |
24 | package org.slf4j.helpers; | |
25 | ||
26 | import java.util.ArrayList; | |
27 | import java.util.Collections; | |
28 | import java.util.List; | |
29 | import java.util.Random; | |
30 | import java.util.concurrent.BrokenBarrierException; | |
31 | import java.util.concurrent.CyclicBarrier; | |
32 | import java.util.concurrent.atomic.AtomicLong; | |
33 | ||
34 | import org.slf4j.Logger; | |
35 | import org.slf4j.LoggerFactory; | |
36 | import org.slf4j.event.EventRecodingLogger; | |
37 | ||
38 | import junit.framework.TestCase; | |
39 | ||
40 | public class NoBindingMultithreadedInitializationTest2 extends TestCase { | |
41 | final protected static int THREAD_COUNT = 4 + Runtime.getRuntime().availableProcessors() * 2; | |
42 | ||
43 | private final List<Logger> createdLoggers = Collections.synchronizedList(new ArrayList<Logger>()); | |
44 | ||
45 | protected final AtomicLong eventCount = new AtomicLong(0); | |
46 | final private CyclicBarrier barrier = new CyclicBarrier(THREAD_COUNT + 1); | |
47 | ||
48 | int diff = new Random().nextInt(10000); | |
49 | ||
50 | ||
51 | public NoBindingMultithreadedInitializationTest2(String name) { | |
52 | super(name); | |
53 | } | |
54 | ||
55 | public void testNoBindingMultiThreadedInitialization() throws InterruptedException, BrokenBarrierException { | |
56 | @SuppressWarnings("unused") | |
57 | LoggerAccessingThread2[] accessors = harness(); | |
58 | ||
59 | Logger logger = LoggerFactory.getLogger(getClass().getName()); | |
60 | logger.info("hello"); | |
61 | eventCount.getAndIncrement(); | |
62 | ||
63 | assertAllSubstLoggersAreFixed(); | |
64 | long recordedEventCount = getRecordedEventCount(); | |
65 | int LENIENCY_COUNT = 16; | |
66 | ||
67 | long expectedEventCount = eventCount.get() + extraLogEvents(); | |
68 | ||
69 | assertTrue(expectedEventCount + " >= " + recordedEventCount, expectedEventCount >= recordedEventCount); | |
70 | assertTrue(expectedEventCount + " < " + recordedEventCount + "+" + LENIENCY_COUNT, | |
71 | expectedEventCount < recordedEventCount + LENIENCY_COUNT); | |
72 | } | |
73 | ||
74 | protected int extraLogEvents() { | |
75 | return 0; | |
76 | } | |
77 | ||
78 | private void assertAllSubstLoggersAreFixed() { | |
79 | for (Logger logger : createdLoggers) { | |
80 | if (logger instanceof SubstituteLogger) { | |
81 | SubstituteLogger substLogger = (SubstituteLogger) logger; | |
82 | if (substLogger.delegate() instanceof EventRecodingLogger) | |
83 | fail("substLogger " + substLogger.getName() + " has a delegate of type EventRecodingLogger"); | |
84 | } | |
85 | } | |
86 | } | |
87 | ||
88 | private LoggerAccessingThread2[] harness() throws InterruptedException, BrokenBarrierException { | |
89 | LoggerAccessingThread2[] threads = new LoggerAccessingThread2[THREAD_COUNT]; | |
90 | for (int i = 0; i < THREAD_COUNT; i++) { | |
91 | threads[i] = new LoggerAccessingThread2(barrier, createdLoggers, i, eventCount); | |
92 | threads[i].start(); | |
93 | } | |
94 | ||
95 | // trigger barrier | |
96 | barrier.await(); | |
97 | ||
98 | for (int i = 0; i < THREAD_COUNT; i++) { | |
99 | threads[i].join(); | |
100 | } | |
101 | ||
102 | return threads; | |
103 | } | |
104 | ||
105 | final String loggerName = this.getClass().getName(); | |
106 | ||
107 | protected long getRecordedEventCount() { | |
108 | return eventCount.get(); | |
109 | } | |
110 | ||
111 | } |
4 | 4 | <parent> |
5 | 5 | <groupId>org.slf4j</groupId> |
6 | 6 | <artifactId>slf4j-parent</artifactId> |
7 | <version>1.7.29</version> | |
7 | <version>1.7.30</version> | |
8 | 8 | </parent> |
9 | 9 | |
10 | 10 | <modelVersion>4.0.0</modelVersion> |
6 | 6 | <parent> |
7 | 7 | <groupId>org.slf4j</groupId> |
8 | 8 | <artifactId>slf4j-parent</artifactId> |
9 | <version>1.7.29</version> | |
9 | <version>1.7.30</version> | |
10 | 10 | </parent> |
11 | 11 | |
12 | 12 | <artifactId>jul-to-slf4j</artifactId> |
6 | 6 | <parent> |
7 | 7 | <groupId>org.slf4j</groupId> |
8 | 8 | <artifactId>slf4j-parent</artifactId> |
9 | <version>1.7.29</version> | |
9 | <version>1.7.30</version> | |
10 | 10 | </parent> |
11 | 11 | |
12 | 12 |
6 | 6 | <parent> |
7 | 7 | <groupId>org.slf4j</groupId> |
8 | 8 | <artifactId>slf4j-parent</artifactId> |
9 | <version>1.7.29</version> | |
9 | <version>1.7.30</version> | |
10 | 10 | </parent> |
11 | 11 | |
12 | 12 | <artifactId>osgi-over-slf4j</artifactId> |
5 | 5 | |
6 | 6 | <groupId>org.slf4j</groupId> |
7 | 7 | <artifactId>slf4j-parent</artifactId> |
8 | <version>1.7.29</version> | |
8 | <version>1.7.30</version> | |
9 | 9 | |
10 | 10 | <packaging>pom</packaging> |
11 | 11 | <name>SLF4J</name> |
6 | 6 | <parent> |
7 | 7 | <groupId>org.slf4j</groupId> |
8 | 8 | <artifactId>slf4j-parent</artifactId> |
9 | <version>1.7.29</version> | |
9 | <version>1.7.30</version> | |
10 | 10 | </parent> |
11 | 11 | |
12 | 12 | <artifactId>slf4j-android</artifactId> |
6 | 6 | <parent> |
7 | 7 | <groupId>org.slf4j</groupId> |
8 | 8 | <artifactId>slf4j-parent</artifactId> |
9 | <version>1.7.29</version> | |
9 | <version>1.7.30</version> | |
10 | 10 | </parent> |
11 | 11 | |
12 | 12 | <artifactId>slf4j-api</artifactId> |
149 | 149 | StaticLoggerBinder.getSingleton(); |
150 | 150 | INITIALIZATION_STATE = SUCCESSFUL_INITIALIZATION; |
151 | 151 | reportActualBinding(staticLoggerBinderPathSet); |
152 | fixSubstituteLoggers(); | |
153 | replayEvents(); | |
154 | // release all resources in SUBST_FACTORY | |
155 | SUBST_FACTORY.clear(); | |
156 | 152 | } catch (NoClassDefFoundError ncde) { |
157 | 153 | String msg = ncde.getMessage(); |
158 | 154 | if (messageContainsOrgSlf4jImplStaticLoggerBinder(msg)) { |
176 | 172 | } catch (Exception e) { |
177 | 173 | failedBinding(e); |
178 | 174 | throw new IllegalStateException("Unexpected initialization failure", e); |
179 | } | |
180 | } | |
175 | } finally { | |
176 | postBindCleanUp(); | |
177 | } | |
178 | } | |
179 | ||
180 | private static void postBindCleanUp() { | |
181 | fixSubstituteLoggers(); | |
182 | replayEvents(); | |
183 | // release all resources in SUBST_FACTORY | |
184 | SUBST_FACTORY.clear(); | |
185 | } | |
181 | 186 | |
182 | 187 | private static void fixSubstituteLoggers() { |
183 | 188 | synchronized (SUBST_FACTORY) { |
21 | 21 | |
22 | 22 | private final List<Logger> createdLoggers = Collections.synchronizedList(new ArrayList<Logger>()); |
23 | 23 | |
24 | final private AtomicLong eventCount = new AtomicLong(0); | |
24 | protected final AtomicLong eventCount = new AtomicLong(0); | |
25 | 25 | final private CyclicBarrier barrier = new CyclicBarrier(THREAD_COUNT + 1); |
26 | 26 | |
27 | 27 | int diff = new Random().nextInt(10000); |
6 | 6 | <parent> |
7 | 7 | <groupId>org.slf4j</groupId> |
8 | 8 | <artifactId>slf4j-parent</artifactId> |
9 | <version>1.7.29</version> | |
9 | <version>1.7.30</version> | |
10 | 10 | </parent> |
11 | 11 | |
12 | 12 | <artifactId>slf4j-ext</artifactId> |
6 | 6 | <parent> |
7 | 7 | <groupId>org.slf4j</groupId> |
8 | 8 | <artifactId>slf4j-parent</artifactId> |
9 | <version>1.7.29</version> | |
9 | <version>1.7.30</version> | |
10 | 10 | </parent> |
11 | 11 | |
12 | 12 | <artifactId>slf4j-jcl</artifactId> |
6 | 6 | <parent> |
7 | 7 | <groupId>org.slf4j</groupId> |
8 | 8 | <artifactId>slf4j-parent</artifactId> |
9 | <version>1.7.29</version> | |
9 | <version>1.7.30</version> | |
10 | 10 | </parent> |
11 | 11 | |
12 | 12 | <artifactId>slf4j-jdk14</artifactId> |
6 | 6 | <parent> |
7 | 7 | <groupId>org.slf4j</groupId> |
8 | 8 | <artifactId>slf4j-parent</artifactId> |
9 | <version>1.7.29</version> | |
9 | <version>1.7.30</version> | |
10 | 10 | </parent> |
11 | 11 | |
12 | 12 | <artifactId>slf4j-log4j12</artifactId> |
6 | 6 | <parent> |
7 | 7 | <groupId>org.slf4j</groupId> |
8 | 8 | <artifactId>slf4j-parent</artifactId> |
9 | <version>1.7.29</version> | |
9 | <version>1.7.30</version> | |
10 | 10 | </parent> |
11 | 11 | |
12 | 12 | <artifactId>slf4j-migrator</artifactId> |
6 | 6 | <parent> |
7 | 7 | <groupId>org.slf4j</groupId> |
8 | 8 | <artifactId>slf4j-parent</artifactId> |
9 | <version>1.7.29</version> | |
9 | <version>1.7.30</version> | |
10 | 10 | </parent> |
11 | 11 | |
12 | 12 | <artifactId>slf4j-nop</artifactId> |