Package list libslf4j-java / b51fe17
New upstream version 1.7.30 Emmanuel Bourg 6 months ago
21 changed file(s) with 227 addition(s) and 29 deletion(s). Raw diff Collapse all Expand all
5555 <pathelement location="../slf4j-simple/target/slf4j-simple-${currentVersion}.jar" />
5656 </path >
5757
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
5964 <path id="incompatibleMultiBinding">
6065 <pathelement location="target/test-classes/" />
6166 <pathelement location="../slf4j-api/target/slf4j-api-${currentVersion}.jar" />
101106 </target>
102107
103108 <target name="testAll" depends="init,
104 testMissingSingletonMethod,
109 testMissingSingletonMethod,
105110 testMismatch,
106 testMatch,
107 testMultiBinding,
108 testIncompatibleMultiBinding,
111 testNoBinding,
112 testMatch,
113 testMultiBinding,
114 testIncompatibleMultiBinding,
109115 testFuture_16Series,
110116 testActiveSecurityManager">
111117 </target>
214220 </junit>
215221
216222 </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
218234
219235 <condition property="runFromWithinIntegrationModule">
220236 <contains string="${user.dir}" substring="integration" />
66 <parent>
77 <groupId>org.slf4j</groupId>
88 <artifactId>slf4j-parent</artifactId>
9 <version>1.7.29</version>
9 <version>1.7.30</version>
1010 </parent>
1111
1212 <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 }
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 }
44 <parent>
55 <groupId>org.slf4j</groupId>
66 <artifactId>slf4j-parent</artifactId>
7 <version>1.7.29</version>
7 <version>1.7.30</version>
88 </parent>
99
1010 <modelVersion>4.0.0</modelVersion>
66 <parent>
77 <groupId>org.slf4j</groupId>
88 <artifactId>slf4j-parent</artifactId>
9 <version>1.7.29</version>
9 <version>1.7.30</version>
1010 </parent>
1111
1212 <artifactId>jul-to-slf4j</artifactId>
66 <parent>
77 <groupId>org.slf4j</groupId>
88 <artifactId>slf4j-parent</artifactId>
9 <version>1.7.29</version>
9 <version>1.7.30</version>
1010 </parent>
1111
1212
66 <parent>
77 <groupId>org.slf4j</groupId>
88 <artifactId>slf4j-parent</artifactId>
9 <version>1.7.29</version>
9 <version>1.7.30</version>
1010 </parent>
1111
1212 <artifactId>osgi-over-slf4j</artifactId>
55
66 <groupId>org.slf4j</groupId>
77 <artifactId>slf4j-parent</artifactId>
8 <version>1.7.29</version>
8 <version>1.7.30</version>
99
1010 <packaging>pom</packaging>
1111 <name>SLF4J</name>
66 <parent>
77 <groupId>org.slf4j</groupId>
88 <artifactId>slf4j-parent</artifactId>
9 <version>1.7.29</version>
9 <version>1.7.30</version>
1010 </parent>
1111
1212 <artifactId>slf4j-android</artifactId>
66 <parent>
77 <groupId>org.slf4j</groupId>
88 <artifactId>slf4j-parent</artifactId>
9 <version>1.7.29</version>
9 <version>1.7.30</version>
1010 </parent>
1111
1212 <artifactId>slf4j-api</artifactId>
149149 StaticLoggerBinder.getSingleton();
150150 INITIALIZATION_STATE = SUCCESSFUL_INITIALIZATION;
151151 reportActualBinding(staticLoggerBinderPathSet);
152 fixSubstituteLoggers();
153 replayEvents();
154 // release all resources in SUBST_FACTORY
155 SUBST_FACTORY.clear();
156152 } catch (NoClassDefFoundError ncde) {
157153 String msg = ncde.getMessage();
158154 if (messageContainsOrgSlf4jImplStaticLoggerBinder(msg)) {
176172 } catch (Exception e) {
177173 failedBinding(e);
178174 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 }
181186
182187 private static void fixSubstituteLoggers() {
183188 synchronized (SUBST_FACTORY) {
2121
2222 private final List<Logger> createdLoggers = Collections.synchronizedList(new ArrayList<Logger>());
2323
24 final private AtomicLong eventCount = new AtomicLong(0);
24 protected final AtomicLong eventCount = new AtomicLong(0);
2525 final private CyclicBarrier barrier = new CyclicBarrier(THREAD_COUNT + 1);
2626
2727 int diff = new Random().nextInt(10000);
66 <parent>
77 <groupId>org.slf4j</groupId>
88 <artifactId>slf4j-parent</artifactId>
9 <version>1.7.29</version>
9 <version>1.7.30</version>
1010 </parent>
1111
1212 <artifactId>slf4j-ext</artifactId>
66 <parent>
77 <groupId>org.slf4j</groupId>
88 <artifactId>slf4j-parent</artifactId>
9 <version>1.7.29</version>
9 <version>1.7.30</version>
1010 </parent>
1111
1212 <artifactId>slf4j-jcl</artifactId>
66 <parent>
77 <groupId>org.slf4j</groupId>
88 <artifactId>slf4j-parent</artifactId>
9 <version>1.7.29</version>
9 <version>1.7.30</version>
1010 </parent>
1111
1212 <artifactId>slf4j-jdk14</artifactId>
66 <parent>
77 <groupId>org.slf4j</groupId>
88 <artifactId>slf4j-parent</artifactId>
9 <version>1.7.29</version>
9 <version>1.7.30</version>
1010 </parent>
1111
1212 <artifactId>slf4j-log4j12</artifactId>
66 <parent>
77 <groupId>org.slf4j</groupId>
88 <artifactId>slf4j-parent</artifactId>
9 <version>1.7.29</version>
9 <version>1.7.30</version>
1010 </parent>
1111
1212 <artifactId>slf4j-migrator</artifactId>
66 <parent>
77 <groupId>org.slf4j</groupId>
88 <artifactId>slf4j-parent</artifactId>
9 <version>1.7.29</version>
9 <version>1.7.30</version>
1010 </parent>
1111
1212 <artifactId>slf4j-nop</artifactId>
66 <parent>
77 <groupId>org.slf4j</groupId>
88 <artifactId>slf4j-parent</artifactId>
9 <version>1.7.29</version>
9 <version>1.7.30</version>
1010 </parent>
1111
1212 <artifactId>slf4j-simple</artifactId>
66 <parent>
77 <groupId>org.slf4j</groupId>
88 <artifactId>slf4j-parent</artifactId>
9 <version>1.7.29</version>
9 <version>1.7.30</version>
1010 </parent>
1111
1212 <artifactId>slf4j-site</artifactId>