Skip to content

Commit 6438b44

Browse files
committed
fix: remove paimon-api threadGroup
1 parent 98c8b75 commit 6438b44

File tree

2 files changed

+98
-0
lines changed

2 files changed

+98
-0
lines changed

connectors/paimon-connector/pom.xml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,12 @@
203203
<exclude>**/org/slf4j/**</exclude>
204204
</excludes>
205205
</filter>
206+
<filter>
207+
<artifact>org.apache.paimon:paimon-api</artifact>
208+
<excludes>
209+
<exclude>org/apache/paimon/utils/ThreadUtils</exclude>
210+
</excludes>
211+
</filter>
206212
</filters>
207213
</configuration>
208214
</execution>
@@ -303,6 +309,25 @@
303309
</execution>
304310
</executions>
305311
</plugin>
312+
<plugin>
313+
<groupId>org.codehaus.mojo</groupId>
314+
<artifactId>build-helper-maven-plugin</artifactId>
315+
<version>3.2.0</version>
316+
<executions>
317+
<execution>
318+
<id>add-source</id>
319+
<phase>generate-sources</phase>
320+
<goals>
321+
<goal>add-source</goal>
322+
</goals>
323+
<configuration>
324+
<sources>
325+
<source>src/main/overwrite/</source>
326+
</sources>
327+
</configuration>
328+
</execution>
329+
</executions>
330+
</plugin>
306331
</plugins>
307332
</build>
308333
</project>
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
//
2+
// Source code recreated from a .class file by IntelliJ IDEA
3+
// (powered by FernFlower decompiler)
4+
//
5+
6+
package org.apache.paimon.utils;
7+
8+
import java.lang.management.ManagementFactory;
9+
import java.lang.management.ThreadInfo;
10+
import java.util.Arrays;
11+
import java.util.concurrent.ThreadFactory;
12+
import java.util.concurrent.atomic.AtomicInteger;
13+
import java.util.stream.Collectors;
14+
import org.slf4j.Logger;
15+
16+
public class ThreadUtils {
17+
public static String currentStackString() {
18+
StackTraceElement[] trace = (StackTraceElement[])Thread.getAllStackTraces().get(Thread.currentThread());
19+
StringBuilder builder = new StringBuilder();
20+
21+
for(StackTraceElement traceElement : trace) {
22+
builder.append("\nat ").append(traceElement);
23+
}
24+
25+
return builder.toString();
26+
}
27+
28+
public static void errorLogThreadDump(Logger logger) {
29+
ThreadInfo[] perThreadInfo = ManagementFactory.getThreadMXBean().dumpAllThreads(true, true);
30+
logger.error("Thread dump: \n{}", Arrays.stream(perThreadInfo).map(Object::toString).collect(Collectors.joining()));
31+
}
32+
33+
public static boolean stackContains(String name) {
34+
StackTraceElement[] ss = (new RuntimeException()).getStackTrace();
35+
36+
for(StackTraceElement s : ss) {
37+
if (s.toString().contains(name)) {
38+
return true;
39+
}
40+
}
41+
42+
return false;
43+
}
44+
45+
public static ThreadFactory newDaemonThreadFactory(String prefix) {
46+
final ThreadFactory namedFactory = getNamedThreadFactory(prefix);
47+
return new ThreadFactory() {
48+
public Thread newThread(Runnable r) {
49+
Thread t = namedFactory.newThread(r);
50+
if (!t.isDaemon()) {
51+
t.setDaemon(true);
52+
}
53+
54+
if (t.getPriority() != 5) {
55+
t.setPriority(5);
56+
}
57+
58+
return t;
59+
}
60+
};
61+
}
62+
63+
private static ThreadFactory getNamedThreadFactory(final String prefix) {
64+
return new ThreadFactory() {
65+
private final AtomicInteger threadNumber = new AtomicInteger(1);
66+
67+
public Thread newThread(Runnable r) {
68+
String name = prefix + "-t" + this.threadNumber.getAndIncrement();
69+
return new Thread(null, r, name);
70+
}
71+
};
72+
}
73+
}

0 commit comments

Comments
 (0)